Repository navigation
fix(cli): resolve dynamic imports to file:// URLs so the DB fallback works on Windows - #11238
Merged
diegosouzapw merged 1 commit intoAug 23, 2026
Conversation
…works on Windows Dynamic import() resolves its specifier as a URL, not as a filesystem path. A POSIX absolute path doubles as a valid relative URL so interpolating it works by accident; a Windows absolute path begins with a drive letter, which the ESM loader parses as the URL scheme 'e:' and rejects: Error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'e:' This broke every CLI command that falls back to direct DB access when the server is offline: combo list/create/delete/switch all exited 1 on Windows. Fixed in runtime.mjs, setup.mjs and serve.mjs by routing through pathToFileURL(). tests/unit/cli-combo-command.test.ts went 1/5 to 5/5. The temp-dir teardown in that file also threw EPERM on Windows because SQLite still held the file open, failing a test whose assertions had passed; it now retries and degrades to best effort. Adds tests/unit/cli/windows-esm-import-paths.test.ts, which greps bin/cli for the bad pattern and loads the db fallback for real. Verified RED before the fix, GREEN after.
This was referenced Aug 23, 2026
diegosouzapw
merged commit Aug 23, 2026
e32b926
into
diegosouzapw:release/v3.8.50
9 of 16 checks passed
diegosouzapw
pushed a commit
that referenced
this pull request
Aug 23, 2026
, #11267) Three reds the PR's CI surfaced after the base advanced past the branch cut — each discriminated with its origin PR: 1. chatcore-translation-paths 'Combo skip behavior' (shard 3/4) — REAL BUG in #11178: the incompatible-reasoning action derivation switched from the explicit fallback config to isComboStep = Boolean(comboStepId || comboExecutionKey). Combos whose records carry no explicit stepId/executionKey (plain model-list combos) had their explicit reasoningTransportFallback: 'skip' config silently degraded to 'drop', contradicting the PR's own stated intent ('combos keep their explicit strategy'). Fix: isComboStep now honors the isCombo marker (isCombo || step ids present). RED->GREEN on the exact CI failing test; the #10959 single-target drop defaults stay green. 2. check-db-rules-classification 'recovery zero importers' (shard 1/4) — STALE GATE, not dead code: #11238 converted bin/cli/runtime.mjs dynamic imports to the Windows-safe projectFileUrl('...') idiom, and the gate's importer regexes only recognized static/from/template import forms. recovery's only importer became invisible. Fix: gate pattern set extended to recognize import(projectFileUrl('…/db/<mod>.ts')). 3. mutation-test-coverage gate — #11267 added tests/unit/quota-exhaustion-cutoff-opencode.test.ts covering src/sse/services/auth.ts without registering it in stryker.conf.json tap.testFiles. Fix: register it (gate green locally). Refs #9985
This was referenced Aug 23, 2026
Merged
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…works on Windows (diegosouzapw#11238) Validated on the combined 12-PR batch board: cli-combo-command + windows-esm-import-paths suites pass, typecheck:core clean. pathToFileURL on the four dynamic-import call sites unbreaks the CLI offline DB fallback on Windows. Thank you @pacocartones!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
omniroute combo list,create,deleteandswitchall exit 1 on Windows whenever the server is offline and the CLI takes its direct-DB fallback path:Cause
import()resolves its specifier as a URL, not as a filesystem path.A POSIX absolute path (
/home/x/src/lib/db/combos.ts) also happens to be a valid relative URL, so interpolating it intoimport()works by accident on Linux and macOS. A Windows absolute path isE:\checkout\src\lib\db\combos.ts, and the loader parses the leading drive letter as the URL schemee:, which it rejects.Four call sites build a specifier this way:
bin/cli/runtime.mjsbin/cli/commands/setup.mjsbin/cli/commands/serve.mjsruntime.mjsis the impactful one:importDbModules()is what everywithRuntime/withDbcaller depends on whenisServerUp()returns false, so the entire offline fallback of the CLI is unreachable on Windows.Fix
Route each specifier through
pathToFileURL(...).href.Verification
tests/unit/cli-combo-command.test.tswas already failing on Windows on a clean checkout ofrelease/v3.8.50(0b41259f3) — this is not a new test:The four failures were
combo create,combo delete,combo listandcombo switch, each assertingexit === 0and getting1.That file also had a second, unrelated Windows problem: its
withComboEnvteardown calledfs.rmSyncon the temp data dir while SQLite still held the file open, throwingEPERMand failing a test whose assertions had all passed. It now retries and degrades to best effort, since the OS reclaims its own temp dir anyway.Regression guard
Adds
tests/unit/cli/windows-esm-import-paths.test.ts, which does two things:bin/clifor theimport(`${SOME_ROOT}/...`)pattern, so a new call site cannot reintroduce this;withDbon the current platform.Verified RED before the fix and GREEN after.
Scope
tests/unit/cli/**reports182 tests, 170 pass, 9 failboth with and without this change — those 9 failures (aliasResolver,buildRunPlan, theoutboundUrlGuardchild-process specs) are pre-existing on0b41259f3and untouched here. I mention it so the number isn't attributed to this PR; happy to open a separate issue for them if useful.