mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-11 01:32:22 +03:00
fix(combo): add missing antigravityProjectPersistence module
Upstream #8894 added an import for preferAntigravityConnectionsWithStoredProject from ../antigravityProjectPersistence.ts in quotaStrategies.ts, but the module itself was never committed — the file doesn't exist anywhere in git history on either side of the merge. Since Next.js's instrumentation hook must load this import chain successfully at boot, the missing module was fatal: the dev server crashed entirely on every fresh start (not just the affected route). Reconstructed conservatively per the call site and the changelog note ("prefer Antigravity connections with stored project"): reorders connections so ones with an already-known projectId (checked via both the direct column and the providerSpecificData.projectId fallback, matching the shape written by antigravityProjectPersist.ts) come first. Fail-open — reorders only, never excludes a connection, consistent with this codebase's established pattern for capability/preference filters elsewhere in combo/. ⚠️ base-red inherited: #9298
This commit is contained in:
36
open-sse/services/antigravityProjectPersistence.ts
Normal file
36
open-sse/services/antigravityProjectPersistence.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Reorder Antigravity provider connections so ones with an already-known
|
||||
* Cloud Code `projectId` are tried first.
|
||||
*
|
||||
* A connection with no stored projectId still works — `ensureAntigravityProjectAssigned()`
|
||||
* (antigravityProjectBootstrap.ts) recovers it via a `loadCodeAssist` round-trip on the
|
||||
* first real request — but that round-trip costs latency, so reset-aware target expansion
|
||||
* should prefer an already-resolved connection over one that will pay that cost.
|
||||
*
|
||||
* Fail-open: this only reorders, it never drops a connection. #8894 added the import for
|
||||
* this module to quotaStrategies.ts but never committed the module itself, which crashed
|
||||
* the whole dev server at the Node.js instrumentation-hook boot step (module not found).
|
||||
*/
|
||||
|
||||
function hasStoredProjectId(connection: Record<string, unknown>): boolean {
|
||||
const direct = connection.projectId;
|
||||
if (typeof direct === "string" && direct.trim().length > 0) return true;
|
||||
|
||||
const providerSpecificData = connection.providerSpecificData;
|
||||
if (providerSpecificData && typeof providerSpecificData === "object") {
|
||||
const nested = (providerSpecificData as Record<string, unknown>).projectId;
|
||||
if (typeof nested === "string" && nested.trim().length > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function preferAntigravityConnectionsWithStoredProject<T extends Record<string, unknown>>(
|
||||
connections: T[]
|
||||
): T[] {
|
||||
const withProject: T[] = [];
|
||||
const withoutProject: T[] = [];
|
||||
for (const connection of connections) {
|
||||
(hasStoredProjectId(connection) ? withProject : withoutProject).push(connection);
|
||||
}
|
||||
return [...withProject, ...withoutProject];
|
||||
}
|
||||
Reference in New Issue
Block a user