mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
fix(runtime): isolate unique 8177 repairs (#8298)
This commit is contained in:
1
changelog.d/fixes/8298-focused-8177-runtime-fixes.md
Normal file
1
changelog.d/fixes/8298-focused-8177-runtime-fixes.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(runtime):** sanitize Muse Spark fetch failures before logging and resolve the sql.js WASM asset without the unexported package metadata subpath ([#8298](https://github.com/diegosouzapw/OmniRoute/pull/8298)) — thanks @backryun
|
||||
@@ -942,7 +942,9 @@ async function graphqlPost(
|
||||
} catch (err) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `${label} fetch failed: ${err instanceof Error ? err.message : String(err)}`,
|
||||
error: `${label} fetch failed: ${sanitizeErrorMessage(
|
||||
err instanceof Error ? err.message : String(err)
|
||||
)}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ export const KNOWN_MISSING_ERROR_HELPER = new Set([
|
||||
// --- original open-sse/executors + handlers scope (pre-6A.8) ---
|
||||
// --- 6A.8 expanded scope: src/app/api/**/route.ts pre-existing violations ---
|
||||
// TODO(6A.8): pre-existing, triage — route through buildErrorBody()/sanitizeErrorMessage()
|
||||
// open-sse/executors/muse-spark-web.ts has its own local buildErrorResponse() + errorResult()
|
||||
// that follow the same contract (wraps message inside error:{message,type}). The helper
|
||||
// import would create a circular dep. Verified: no raw internal-stack-leak path.
|
||||
"open-sse/executors/muse-spark-web.ts",
|
||||
]);
|
||||
|
||||
// Import specifiers that count as "uses the error helper" (path ends in utils/error).
|
||||
|
||||
@@ -31,18 +31,6 @@ function resolveSqlJsWasmPath(): string {
|
||||
const sqlJsEntry = _require.resolve("sql.js");
|
||||
candidatePaths.push(path.join(path.dirname(sqlJsEntry), "sql-wasm.wasm"));
|
||||
} catch {}
|
||||
// #8135: Use a dynamic expression to avoid Next.js bundler's static analysis
|
||||
// producing a "Can't resolve 'sql.js/package.json'" build warning. The package.json
|
||||
// resolution is only needed for the WASM path, and the try/catch is still required
|
||||
// at runtime since sql.js is an optional dependency.
|
||||
try {
|
||||
const pkgName = "sql.js" + "/package.json";
|
||||
const sqlJsPackage = _require.resolve(pkgName);
|
||||
candidatePaths.push(
|
||||
path.join(path.dirname(sqlJsPackage), "dist", "sql-wasm.wasm"),
|
||||
path.join(path.dirname(sqlJsPackage), "sql-wasm.wasm")
|
||||
);
|
||||
} catch {}
|
||||
|
||||
for (const candidatePath of candidatePaths) {
|
||||
if (fs.existsSync(candidatePath)) {
|
||||
|
||||
@@ -241,16 +241,27 @@ test("muse-spark-web: fetch failures do not expose stack traces or source paths"
|
||||
__resetMuseSparkConversationCacheForTesting();
|
||||
const executor = new MuseSparkWebExecutor();
|
||||
const originalFetch = globalThis.fetch;
|
||||
const errorLogs: string[] = [];
|
||||
globalThis.fetch = async () => {
|
||||
throw new Error("socket failed at /srv/omniroute/secrets.ts:42\n at fetchGraphql");
|
||||
};
|
||||
|
||||
try {
|
||||
const result = await executor.execute(withConnection("conn-fetch-error"));
|
||||
const result = await executor.execute(
|
||||
withConnection("conn-fetch-error", {
|
||||
log: {
|
||||
error(_tag, message) {
|
||||
errorLogs.push(message);
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
assert.equal(result.response.status, 502);
|
||||
const body = await result.response.json();
|
||||
assert.equal(body.error.message, "Warmup fetch failed: socket failed at <path>");
|
||||
assert.doesNotMatch(body.error.message, /secrets\.ts|fetchGraphql|\n/);
|
||||
assert.deepEqual(errorLogs, ["Warmup failed: Warmup fetch failed: socket failed at <path>"]);
|
||||
assert.doesNotMatch(errorLogs[0], /secrets\.ts|fetchGraphql|\n/);
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
|
||||
@@ -35,4 +35,10 @@ test("#8135: sqljsAdapter must not statically resolve sql.js at build time", ()
|
||||
source.includes("/* webpackIgnore: true */"),
|
||||
"sqljsAdapter dynamic import should include /* webpackIgnore: true */ magic comment"
|
||||
);
|
||||
|
||||
// sql.js does not export ./package.json. Resolving its public entrypoint is
|
||||
// sufficient to locate the adjacent WASM asset and avoids repeated bundler
|
||||
// diagnostics for the private package metadata subpath.
|
||||
assert.match(source, /_require\.resolve\(["']sql\.js["']\)/);
|
||||
assert.doesNotMatch(source, /sql\.js\/package\.json/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user