From 9535fa52a6ac007d3fd0ca28f5c857d8282ba70b Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com> Date: Sat, 6 Jun 2026 21:15:43 -0300 Subject: [PATCH] fix(startup): correct autoRefreshDaemon import alias (@/ -> @omniroute/open-sse) (#3292) (#3335) instrumentation-node.ts imported the #3292 cookie auto-refresh daemon via "@/open-sse/services/autoRefreshDaemon". The @/ alias maps to src/, but the daemon lives in the open-sse workspace, so the import resolved to the non-existent src/open-sse/... and threw "Cannot find module" at runtime in the built standalone. A try/catch made it non-fatal (the daemon silently never ran), which kept typecheck and the dev server green, but the packaged Electron app's strict startup-log smoke test failed on the "Cannot find module" line. Use the correct @omniroute/open-sse alias, plus a regression test banning @/open-sse/* imports across src/. --- src/instrumentation-node.ts | 4 +- tests/unit/no-src-open-sse-alias.test.ts | 51 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/unit/no-src-open-sse-alias.test.ts diff --git a/src/instrumentation-node.ts b/src/instrumentation-node.ts index 965b857a8c..cc3bfa9ea4 100755 --- a/src/instrumentation-node.ts +++ b/src/instrumentation-node.ts @@ -239,7 +239,9 @@ export async function registerNodejs(): Promise { } try { - const { autoRefreshDaemon } = await import("@/open-sse/services/autoRefreshDaemon"); + const { autoRefreshDaemon } = await import( + "@omniroute/open-sse/services/autoRefreshDaemon" + ); autoRefreshDaemon.start(); } catch (err: unknown) { const msg = err instanceof Error ? err.message : String(err); diff --git a/tests/unit/no-src-open-sse-alias.test.ts b/tests/unit/no-src-open-sse-alias.test.ts new file mode 100644 index 0000000000..28fae19298 --- /dev/null +++ b/tests/unit/no-src-open-sse-alias.test.ts @@ -0,0 +1,51 @@ +/** + * Regression guard (#3292 / v3.8.13 Electron release fragment). + * + * `@/*` maps to `src/*`, but the streaming engine lives in the `open-sse/` + * workspace (alias `@omniroute/open-sse/*`). So an import of `@/open-sse/...` + * resolves to the non-existent `src/open-sse/...` and throws + * "Cannot find module '@/open-sse/...'" at runtime in the built standalone. + * + * This bit the #3292 auto-refresh daemon: `instrumentation-node.ts` did + * `await import("@/open-sse/services/autoRefreshDaemon")`. It was caught by a + * try/catch (non-fatal), so typecheck and the dev server stayed green, but the + * packaged Electron app's strict startup-log smoke test failed on the + * "Cannot find module" line. This test fails fast on any such alias. + */ + +import test from "node:test"; +import assert from "node:assert/strict"; +import { readdirSync, readFileSync, statSync } from "node:fs"; +import { join } from "node:path"; + +const srcRoot = join(import.meta.dirname, "../../src"); + +function walk(dir: string): string[] { + const out: string[] = []; + for (const entry of readdirSync(dir)) { + const full = join(dir, entry); + if (statSync(full).isDirectory()) { + out.push(...walk(full)); + } else if (/\.(ts|tsx|js|mjs)$/.test(entry)) { + out.push(full); + } + } + return out; +} + +test("src/ never imports the open-sse workspace via the @/ alias (use @omniroute/open-sse)", () => { + const offenders: string[] = []; + for (const file of walk(srcRoot)) { + const src = readFileSync(file, "utf8"); + // matches from "@/open-sse/... and import("@/open-sse/... + if (/["'`]@\/open-sse\//.test(src)) { + const line = src.split("\n").findIndex((l) => /["'`]@\/open-sse\//.test(l)) + 1; + offenders.push(`${file.replace(srcRoot, "src")}:${line}`); + } + } + assert.deepEqual( + offenders, + [], + `@/open-sse/* resolves to the non-existent src/open-sse/* and throws "Cannot find module" at runtime. Use @omniroute/open-sse/* instead. Offenders:\n${offenders.join("\n")}` + ); +});