Skip to content

fix(ci): use temp config dir in npm smoke test to prevent WASM SQLite crash - #1282

Merged
MathurAditya724 merged 1 commit into
mainfrom
fix/ci-smoke-test-auth-leak
Jul 22, 2026
Merged

fix(ci): use temp config dir in npm smoke test to prevent WASM SQLite crash#1282
MathurAditya724 merged 1 commit into
mainfrom
fix/ci-smoke-test-auth-leak

Conversation

@MathurAditya724

Copy link
Copy Markdown
Member

Problem

The Build npm Package (smoke Node 20) job fails on main with:

Fatal: SQLite3Error: unable to open database file

This persisted after #1278 (which cleared auth tokens but didn't fix the root cause).

Root Cause

The WASM SQLite driver (used on Node 20 since node:sqlite is unavailable before 22.15) cannot open the database file at ~/.sentry/cli.db when the smoke test runs after switching from Node 22 to Node 20. The runner's home directory state from the Node 22 build step may include a ~/.sentry directory with permissions or lock state incompatible with the WASM driver's Node.js VFS layer (which uses fs.openSync/mkdirSync for locking, unlike the native driver).

Why PRs pass but main fails: On PR runs, the production environment is not activated (conditional on line 782), so SENTRY_AUTH_TOKEN is empty and the CLI takes a lighter code path. On main, the token leaks from the Bundle step, causing earlier database initialization before the --help fast path can avoid it.

Fix

  1. Clear auth tokens in both smoke test steps (from fix(ci): clear auth tokens in npm smoke test to prevent WASM SQLite crash #1278)
  2. Set SENTRY_CONFIG_DIR to ${{ runner.temp }}/.sentry-smoke so the WASM driver creates a fresh database in a known-writable temp directory, avoiding any state left by the Node 22 build step

This matches the approach used in test infrastructure (useTestConfigDir) — isolate the config directory to prevent cross-runtime state interference.

@MathurAditya724
MathurAditya724 force-pushed the fix/ci-smoke-test-auth-leak branch from 7225abb to eb59204 Compare July 22, 2026 19:02
@github-actions github-actions Bot added the risk: high PR risk score: high label Jul 22, 2026
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 5486 uncovered lines.
✅ Project coverage is 81.69%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.69%    81.69%        —%
==========================================
  Files          426       426         —
  Lines        29969     29969         —
  Branches     19496     19496         —
==========================================
+ Hits         24483     24483         —
- Misses        5486      5486         —
- Partials      2045      2045         —

Generated by Codecov Action

… crash

The 'Build npm Package (smoke Node 20)' job fails on main with:

  Fatal: SQLite3Error: unable to open database file

Root cause: the WASM SQLite driver (used on Node 20 since node:sqlite is
unavailable before 22.15) cannot open the database file at ~/.sentry/cli.db
when the smoke test runs after switching from Node 22 to Node 20. The
runner's home directory state from the Node 22 build step may include a
~/.sentry directory with permissions or lock state incompatible with the
WASM driver's Node.js VFS layer (which uses fs.openSync/mkdirSync for
locking, unlike the native driver).

The PR's CI was green because on PR runs, the 'production' environment is
not activated (conditional on line 782), so SENTRY_AUTH_TOKEN is empty and
the CLI takes a lighter code path that doesn't hit the database as early.
On main, the token leaks from the Bundle step into the smoke test step,
causing the CLI to initialize telemetry earlier, which triggers database
access before the --help fast path can avoid it.

Fix:
1. Clear SENTRY_AUTH_TOKEN and SENTRY_TOKEN (already done in first fix)
2. Set SENTRY_CONFIG_DIR to runner.temp/.sentry-smoke so the WASM driver
   creates a fresh database in a known-writable temp directory, avoiding
   any state left by the Node 22 build step
@MathurAditya724
MathurAditya724 force-pushed the fix/ci-smoke-test-auth-leak branch from eb59204 to 39b845e Compare July 22, 2026 19:07
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: high PR risk score: high labels Jul 22, 2026
@MathurAditya724
MathurAditya724 enabled auto-merge (squash) July 22, 2026 19:12
@MathurAditya724
MathurAditya724 merged commit d904166 into main Jul 22, 2026
33 checks passed
@MathurAditya724
MathurAditya724 deleted the fix/ci-smoke-test-auth-leak branch July 22, 2026 19:14
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-22 19:14 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant