fix(ci): clear auth tokens in npm smoke test to prevent WASM SQLite crash - #1278
Merged
Conversation
…rash The 'Build npm Package (smoke Node 20)' job has been failing on main with: Fatal: SQLite3Error: unable to open database file Root cause: the build-npm job uses `environment: production` (line 782) so that the Bundle step can access SENTRY_AUTH_TOKEN for sourcemap uploads. This token leaks into subsequent steps. When the smoke test runs `node dist/bin.cjs --help` on Node 20 (WASM SQLite fallback), the CLI detects the auth token, initializes telemetry, and opens the SQLite database — but the WASM driver fails because the runner's ~/.sentry config directory hasn't been set up for the switched Node 20 runtime. On PR runs, SENTRY_AUTH_TOKEN is empty (the `production` environment is only activated for main/release branches), so the CLI skips telemetry init and the smoke test passes. This is why the PR's CI was green but main's CI is red. Fix: explicitly clear SENTRY_AUTH_TOKEN and SENTRY_TOKEN in the first smoke test step, matching what the deep smoke test already does.
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 5487 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.69% 81.69% —%
==========================================
Files 426 426 —
Lines 29969 29969 —
Branches 19496 19496 —
==========================================
+ Hits 24482 24482 —
- Misses 5487 5487 —
- Partials 2046 2043 -3Generated by Codecov Action |
Contributor
|
MathurAditya724
added a commit
that referenced
this pull request
Jul 22, 2026
… 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.
5 tasks
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.
Problem
The
Build npm Package (smoke Node 20)job has been failing on main with:Both recent main commits show this failure:
b5902f2(fix(local): Handle standalone span items...)b6e89b5(fix(init): retry transient auth validation once)The PRs that merged into main passed CI, but the same code fails on main.
Root Cause
The
build-npmjob usesenvironment: production(line 782) so the Bundle step can accessSENTRY_AUTH_TOKENfor sourcemap uploads. This token leaks into all subsequent steps in the job.When the first smoke test runs
node dist/bin.cjs --helpon Node 20:SENTRY_AUTH_TOKENin the environmentnode:sqlitebefore 22.15)_nodejs_openfails because the runner's~/.sentryconfig directory doesn't exist yet for the switched Node 20 runtimeWhy PRs pass but main fails: On PR runs,
environment: productionresolves to empty (the conditional on line 782 only activates formain/release/*branches), soSENTRY_AUTH_TOKENis empty. Without a token, the CLI skips telemetry init and never opens the database.Fix
Explicitly clear
SENTRY_AUTH_TOKENandSENTRY_TOKENin the first smoke test step'senv:block — matching what the deep smoke test step already does (lines 835-836).This is the minimal, correct fix. The smoke tests are consumer-perspective tests that should run without auth credentials.