GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(cli): Read a WAL-mode database on the WASM SQLite driver by sentry-junior[bot] · Pull Request #2069 · getsentry/toolkit

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 7, 2026 •
edited by BYK
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

On Node 22.15+ and in the binary, the native driver puts cli.db in WAL mode. That setting lives in the file header, so it is still there after the process exits. The WASM fallback (Node 20–22.14, Bun) has no shared memory, so it can't open a WAL database at all. Every statement that reads the file fails with unable to open database file.

This breaks whenever one machine runs the CLI on two runtimes. A common case: an agent runs npx sentry on a newer Node, and then the project's bundler plugin loads sentry on the project's older pinned Node. release.create and sourcemap.upload fail, the plugin swallows the error, and sourcemaps quietly go missing.

On open, the WASM driver now checks the header. If the file is in WAL mode, it switches it back to a rollback journal with locking_mode = EXCLUSIVE → journal_mode = DELETE → locking_mode = NORMAL. In exclusive mode SQLite can read WAL without shared memory, so no data is lost. The native driver turns WAL back on the next time it opens the file.

If a -shm file exists, the switch is skipped, because a native process may still have the database open. In that case the open fails just as it does today. #2068 handles that case by falling back to an in-memory database.

Reported by @sergical.

Fixes #2067

via @BYK.

--

View Session in Sentry

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sentry-junior @BYK
fix(cli): Read a WAL-mode database on the WASM SQLite driver
17af0f7
The native driver leaves cli.db in WAL mode, which the WASM fallback (Node 20-22.14, Bun) cannot open. Switch the file back to a rollback journal on open so the next statement doesn't fail with "unable to open database file".

Fixes #2067

Co-Authored-By: BYK <[email protected]>
@sentry-junior sentry-junior Bot assigned BYK Nov 7, 2026
@vercel

vercel Bot commented Nov 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 7, 2026 12:22am UTC

Request Review

sentry-junior[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 7, 2026
BYK
BYK approved these changes Nov 7, 2026
View reviewed changes

@BYK BYK left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check if there are other users of the DB before overriding WAL mode?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sentry-junior sentry-junior Bot mentioned this pull request Nov 7, 2026
fix(cli): Use an in-memory database when cli.db won't open #2070
Merged
@sentry-junior

sentry-junior Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Good question. It does check, in the way that matters: the switch is skipped while cli.db-shm exists. I checked this on Node 22.23. While a node:sqlite connection has a WAL-mode database open, both -shm and -wal exist, and the last close deletes them. So a live native user always leaves -shm on disk, and we leave its database alone. A covering test is in sqlite.test.ts: "leaves WAL mode alone while a -shm file exists".

Other cases:

  • Another WASM process: it can't be using a WAL database at all, since that's the bug. If it is in the middle of the same switch, our EXCLUSIVE + journal_mode pragmas hit its lock dir and fail with busy. That error surfaces from the constructor, and fix(cli): Use an in-memory database when cli.db won't open #2070 turns it into the in-memory fallback.
  • A crashed native process: it leaves -shm behind, so we skip the switch and fall back the same way. The next native run cleans up the leftover -shm.
  • What it can't catch: a native connection that has opened the file but hasn't read it yet, so it has no -shm yet. getDatabase() runs journal_mode = WAL right after opening, so that window is tiny. Native and WASM also lock in different ways (fcntl vs. a mkdir lock dir) and can't see each other's locks. That's already true for any concurrent mix of the two drivers today, and this PR doesn't make it worse.

So I didn't add another check. The only stronger signal would be probing the fcntl locks on -shm, and JS can't do that without a native addon.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BYK
BYK merged commit 8b973ec into main Nov 7, 2026
27 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@BYK
BYK deleted the fix/cli-wasm-wal-db branch November 7, 2026 00:41
BYK added a commit that referenced this pull request Nov 7, 2026
@sentry-junior @BYK
fix(cli): Use an in-memory database when cli.db won't open (#2070)
9c6b9d0
`cli.db` only holds caches and settings, but if it couldn't be opened,
every command failed. That included `release.create` and
`sourcemap.upload` called from `@sentry/bundler-plugins`, even though a
token passed to `createSentrySDK({ token })` never comes from the
database. The plugin swallows the error, so builds passed and sourcemaps
were never uploaded.

Now, when `getDatabase()` can't open, set up, or migrate `cli.db`, it
logs a warning and uses an in-memory database for the rest of the
process. This covers a WAL file the WASM driver can't read (#2067, fixed
separately in #2069), a config directory that can't be created, and a
corrupt file. Shell completion already silences the read-only warning,
and it now silences this one too, so pressing TAB doesn't print into the
prompt. `getRawDatabase()` still throws the original error, so `cli fix`
and the upgrade backup and restore never treat the in-memory copy as
`cli.db`.

I left out the optional part of #2068, which would always use an
in-memory database in library mode when a token is passed. With this
fallback in place it isn't needed for correctness, and keeping `cli.db`
saves region and project lookups on every build.

Reported by Sergiy.

Fixes #2068

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A87622ce3671938950bc6e630 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A87622ce3671938950bc6e630/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
@sentry-junior sentry-junior Bot mentioned this pull request Nov 7, 2026
feat(cli): Make SDK calls write no local state by default #2074
Merged
BYK added a commit that referenced this pull request Nov 7, 2026
@sentry-junior @BYK
feat(cli): Make SDK calls write no local state by default (#2074)
b99e345
Closes #1897.

`createSentrySDK()` calls now write no local state by default. They
still read what the CLI stored, so stored logins, defaults and cached
lookups in `cli.db` work, and so do `.sentryclirc` files and the custom
CA file. They never create or change `cli.db`, and the response cache
and version check are off. Pass `persist: true` to get the old behavior,
where SDK calls write state like the CLI.

How it works:
- The SDK sets an internal `SENTRY_CLI_NO_PERSISTENCE` flag in the
per-call env that `withEnv` already isolates, so the setting applies to
that call only.
- With the flag set, `getDatabase()` returns a read-only view of the
shared connection that only runs `SELECT` statements. Everything else is
dropped, including the `DELETE ... RETURNING` drains (telemetry queue,
completion queue) that read through `get()`/`all()`.
- When there's no `cli.db`, or it won't open (the WAL/driver cases from
#2069 and #2070, or a runtime with no SQLite driver), calls get a null
store and no warning. The null store skips schema setup entirely.
- Telemetry no longer depends on `persist`. It keeps its own opt-outs
(`SENTRY_CLI_NO_TELEMETRY`, `DO_NOT_TRACK`).

A new `env` option sets the environment each call starts from (default
`process.env`). On a server, pass `env` with only what the call needs,
so the server's own `SENTRY_DSN` doesn't change target resolution.

Behavior changes without `persist: true`:
- List commands reject `cursor: "next"`/`"prev"`, since the cursor stack
isn't written. Pass the returned `nextCursor` instead. `"first"` and raw
cursors work. The e2e test that pages with `cursor: "next"` now passes
`persist: true`.
- `getRawDatabase()` throws, so `cli fix` and `cli upgrade` need
`persist: true`.
- Opening an existing `cli.db` still runs the schema setup and
migrations any CLI run does, which can write on an older schema.

Also in here:
- The `.sentryclirc` caches are keyed by the active `SENTRY_CONFIG_DIR`,
since `env` can change it per call.
- The Spleen font loads on first use instead of at import.

This is a breaking change for SDK users, but the package is still `0.x`.
The bundler plugins pin `sentry@^0.45`, so they pick up the new default
only when they bump on purpose. That bump is the fix for the plugins'
`cli.db` failures. Module-level state shared between calls in one
process (the shared connection, the Sentry client, the custom-header and
region caches) is left to #1898.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A87622ce3671938950bc6e630 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A87622ce3671938950bc6e630/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
@sentry-release-bot sentry-release-bot Bot mentioned this pull request Nov 7, 2026
publish: getsentry/toolkit/packages/[email protected] getsentry/publish#10288
Closed
7 tasks done
This was referenced Nov 7, 2026
Bump the sentry CLI dependency to ^0.49.0 getsentry/sentry-javascript#26197
Closed
fix(deps): Bump the sentry CLI to ^0.49.0 getsentry/sentry-javascript#26200
Merged
BYK added a commit to getsentry/sentry-javascript that referenced this pull request Nov 7, 2026
@sentry-junior @BYK
fix(deps): Bump the sentry CLI to ^0.49.0 (#26200)
6c6c040
**Why:** Before `sentry` 0.49.0, every `createSentrySDK()` call opened
and wrote the CLI's local `cli.db`. When a build runs on a different
Node version than the one that created that file (for example through
`npx sentry`), the open fails with `SQLite3Error: unable to open
database file`. The build still passes, but release creation and source
map uploads fail silently. In 0.49.0, SDK calls write no local state by
default (getsentry/toolkit#2074) and fall back to running without
`cli.db` (getsentry/toolkit#2069, getsentry/toolkit#2070). This bumps
`@sentry/bundler-plugins`, `@sentry/remix` and `@sentry/react-router`,
plus the bundler plugin integration tests so the workspace resolves a
single version. None of them set `persist`, so the new default applies
as-is.

**How to review:** The four `package.json` ranges and the lockfile.
0.49.0 was published today, so pnpm added it to
`minimumReleaseAgeExclude`, as with the earlier first-party `@sentry/*`
entries there.

**Unsure about:** The `cloudflare-*-send-to-sentry` e2e apps pin
`sentry@~0.44.1` on their own. I left them alone because they're
separate test apps and don't go through the bundler plugin.

Closes #26197

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A87622ce3671938950bc6e630 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A87622ce3671938950bc6e630/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was previously deployed

1 inactive deployment
Preview — 17af0f7b Deployed Nov 7, 2026 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@BYK BYK BYK approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@BYK BYK

Labels

risk: medium PR risk score: medium

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

WASM SQLite driver can't open a WAL-mode cli.db

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@BYK
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.