Skip to content

Fix offline quarto run losing cached npm packages - #15227

Open
cderv wants to merge 2 commits into
mainfrom
fix/deno-std-cache-sidecar-reset
Open

cderv wants to merge 2 commits into
mainfrom
fix/deno-std-cache-sidecar-reset

Conversation

@cderv

@cderv cderv commented Oct 29, 2026

Copy link
Copy Markdown
Member

Since Quarto 1.9, TypeScript scripts run by Quarto (quarto run, project pre- and post-render scripts, Jupyter filters) can lose the npm packages they downloaded. Offline, the next run then fails with npm package not found in cache ... --cached-only is specified. This reproduces on Windows with the 1.11.8 release build.

Root cause

Quarto ships a pre-populated Deno cache and copies it to the user cache directory on first use. Before each script run, initDenoCache() in src/core/run/deno.ts compares the file names of the bundled cache with the user copy. If any bundled file is missing, it deletes the user copy and copies the bundled cache again, which also drops every npm package downloaded since.

Since the update to Deno 2.4.5, deno cache can exit before closing its SQLite cache databases when the bundled cache is built. The bundled cache then ships the -shm and -wal files of dep_analysis_cache_v2 and node_analysis_cache_v2. It depends on timing: the Windows Zip of 1.11.8 has them, the macOS and Linux tarballs of the same release run don't. When a later Deno process closes one of these databases cleanly, SQLite deletes those files from the user copy, and the next run resets the cache.

Fix

The comparison now skips the SQLite sidecar files of Deno's *_cache_v2 databases. The match is narrow, so a package file whose name ends in -wal still counts as missing, and so does a missing database file. The sidecars are still copied with the bundled cache, because a database with un-checkpointed changes is only valid together with its -wal file.

On Windows with the bundled cache from the 1.11.8 release, 30 offline runs after a clean close of the database keep the cache. Without the fix, the first offline run resets it. Producing a bundled cache without these files at build time is left for a follow-up.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code, Codex
  • Codebase grounding: local clone
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

cderv added 2 commits October 29, 2026 16:46
Since Deno 2.4.5 (Quarto 1.9), `deno cache` can exit before closing its
SQLite cache databases while building the bundled deno_std seed. The
seed then ships un-checkpointed `-shm`/`-wal` files next to
`dep_analysis_cache_v2` and `node_analysis_cache_v2`.

When a later runtime Deno process closes one of these databases
cleanly, SQLite deletes the sidecars from the user copy. The next
`initDenoCache()` sees seed paths missing from the user copy, wipes the
cache and recopies the seed, dropping the downloaded npm packages.
Offline runs then fail with "npm package not found in cache".

Skip the sidecars of Deno's `*_cache_v2` databases when comparing the
seed listing with the user listing. The match is narrow so package
files that happen to end in `-wal` or `-shm` still count as drift, and
a missing database file still triggers a reset. The copy keeps sidecars,
since a seed database with an un-checkpointed WAL is only valid together
with its WAL.
@posit-snyk-bot

posit-snyk-bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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