Skip to content

Commit d904166

Browse files
fix(ci): use temp config dir in npm smoke test to prevent WASM SQLite crash (#1282)
## 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 #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.
1 parent b2b1c9c commit d904166

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -819,21 +819,22 @@ jobs:
819819
node-version: ${{ matrix.node == '24' && env.NODE_VERSION_24 || matrix.node == '20' && env.NODE_VERSION_20 || env.NODE_VERSION_22 }}
820820
- name: Smoke test (Node.js)
821821
env:
822-
# Clear auth tokens so the CLI doesn't attempt API calls or
823-
# telemetry uploads during the smoke test. On main, the job
824-
# inherits SENTRY_AUTH_TOKEN from the `production` environment
825-
# (needed by the Bundle step); without clearing it here, the
826-
# CLI tries to initialize telemetry → SQLite, which crashes on
827-
# the WASM fallback path (Node 20) because the runner's home
828-
# directory may not have a writable ~/.sentry config dir yet.
822+
# Clear auth tokens — on main the job inherits SENTRY_AUTH_TOKEN
823+
# from the production environment (for the Bundle step's sourcemap
824+
# upload). The smoke tests must not use it.
829825
SENTRY_AUTH_TOKEN: ""
830826
SENTRY_TOKEN: ""
827+
# Use a temp config dir so the WASM SQLite driver (Node 20) can
828+
# create and open the database reliably. The runner's ~/.sentry
829+
# may not exist under the switched Node 20 runtime.
830+
SENTRY_CONFIG_DIR: ${{ runner.temp }}/.sentry-smoke
831831
run: node dist/bin.cjs --help
832832
- name: Smoke test (Node.js — deep)
833833
shell: bash
834834
env:
835835
SENTRY_AUTH_TOKEN: ""
836836
SENTRY_TOKEN: ""
837+
SENTRY_CONFIG_DIR: ${{ runner.temp }}/.sentry-smoke
837838
run: |
838839
# auth status without a token exercises SQLite init, schema
839840
# migrations, telemetry lazy import, and the CJS require chain.

0 commit comments

Comments
 (0)