Skip to content

fix: resolve Windows Electron build failures for missing native modules - #8959

Merged
diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.50from
CHIRAG-DAMANI-08:fix/windows-electron-build
Aug 6, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.50from
CHIRAG-DAMANI-08:fix/windows-electron-build

Conversation

@CHIRAG-DAMANI-08

Copy link
Copy Markdown
Contributor
  • audit.ts: replace import('better-sqlite3') with createRequire() to avoid Webpack static resolution failure when the optional dependency is absent

  • omp.ts: replace top-level import with lazy getDatabaseClass() wrapped in try/catch — returns null gracefully instead of crashing the process at module load

  • electron/package.json: set buildDependenciesFromSource=false and npmRebuild=false to skip MSBuild/Windows SDK requirement during packaging

Summary

  • Describe the user-facing or operational change.

Related Issues

  • Closes #
  • Related to #

Validation

Run only the focused loop for what you changed — the full unit suite, Vitest, the
60% coverage gate, and the production build all run in CI on this PR (#8329):

  • Focused tests for the change: node --import tsx/esm --test tests/unit/<file>.test.ts
  • npm run lint
  • Production-code changes include a new or updated automated test in this PR
  • SonarQube PR analysis is green or any remaining issues are explicitly documented below

Tests Added Or Updated

  • List every changed or added automated test file.
  • If no production code changed, state that here.

Coverage Notes

  • If this PR changes src/, open-sse/, electron/, or bin/, explain which tests cover the change.
  • If coverage moved down in any touched file, explain why and what follow-up task will recover it.

Reviewer Notes

  • Call out any risky areas, migrations, feature flags, or manual validation that reviewers should know about.

- audit.ts: replace import('better-sqlite3') with createRequire() to avoid Webpack static resolution failure when the optional dependency is absent

- omp.ts: replace top-level import with lazy getDatabaseClass() wrapped in try/catch — returns null gracefully instead of crashing the process at module load

- electron/package.json: set buildDependenciesFromSource=false and npmRebuild=false to skip MSBuild/Windows SDK requirement during packaging
@diegosouzapw
diegosouzapw merged commit 66b8546 into diegosouzapw:release/v3.8.50 Aug 6, 2026
3 checks passed
diegosouzapw added a commit that referenced this pull request Aug 6, 2026
…e from (#9559)

* fix(mcp): give the audit tests a loader seam createRequire cannot hide from

Since #8959 the audit DB loads better-sqlite3 via createRequire() (so
Electron/global-install resolution works) — which vi.doMock cannot
intercept: it only patches Vitest's ESM module graph. The audit.test.ts
better-sqlite3 mock therefore never engaged; the tests opened a REAL
empty sqlite file in the temp DATA_DIR ('no such table: mcp_tool_audit'
on stderr) and every mock assertion counted zero calls. The 3 failures
are deterministic (reproduced 3/3 locally), redding Vitest (fast-path)
for the entire PR queue — long misdiagnosed as a flake (#9095 merge
notes call it 'pre-existing audit.test.ts flake').

- Shutdown tests inject the mock through the audit connection cache
  (globalThis.__omnirouteMcpAuditDb) — the module's own seam.
- The node:sqlite fallback test drives __setBetterSqliteLoaderForTests,
  a test-only loader override; the production createRequire path is
  untouched (node:sqlite itself is import()'d, so its doMock still
  works).

3/3 red -> 3/3 green; full open-sse/mcp-server vitest suite 88/88.

* chore: align changelog slug with the PR number (9559)

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…es (diegosouzapw#8959)

Validated in local merge-train (devbox-vm-06-dev002) @ combined-tip (FAST gates green: static + changed tests + vitest — only pre-existing audit.test.ts flake). Evidence: /home/diegosouzapw/dev/proxys/OmniRoute/.claude/worktrees/merge-train-20260805-213228-suite.log
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…e from (diegosouzapw#9559)

* fix(mcp): give the audit tests a loader seam createRequire cannot hide from

Since diegosouzapw#8959 the audit DB loads better-sqlite3 via createRequire() (so
Electron/global-install resolution works) — which vi.doMock cannot
intercept: it only patches Vitest's ESM module graph. The audit.test.ts
better-sqlite3 mock therefore never engaged; the tests opened a REAL
empty sqlite file in the temp DATA_DIR ('no such table: mcp_tool_audit'
on stderr) and every mock assertion counted zero calls. The 3 failures
are deterministic (reproduced 3/3 locally), redding Vitest (fast-path)
for the entire PR queue — long misdiagnosed as a flake (diegosouzapw#9095 merge
notes call it 'pre-existing audit.test.ts flake').

- Shutdown tests inject the mock through the audit connection cache
  (globalThis.__omnirouteMcpAuditDb) — the module's own seam.
- The node:sqlite fallback test drives __setBetterSqliteLoaderForTests,
  a test-only loader override; the production createRequire path is
  untouched (node:sqlite itself is import()'d, so its doMock still
  works).

3/3 red -> 3/3 green; full open-sse/mcp-server vitest suite 88/88.

* chore: align changelog slug with the PR number (9559)

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants