Skip to content

Reserve the transient .quarto_ipynb before writing it - #15364

Open
EnginKarahan wants to merge 1 commit into
quarto-dev:mainfrom
EnginKarahan:fix-quarto-ipynb-race
Open

EnginKarahan wants to merge 1 commit into
quarto-dev:mainfrom
EnginKarahan:fix-quarto-ipynb-race

Conversation

@EnginKarahan

Copy link
Copy Markdown

Description

Fixes #15361. target() in the Jupyter engine picked the name of the transient notebook with an existsSync loop and wrote the file only after await quartoMdToJupyter(...). A render and a concurrent quarto inspect of the same document both saw a free name, and the first to finish removed the notebook the other one was still using. The name is now reserved by creating the file with createNew in a small helper, reserveTransientNotebook, and a failed conversion removes the reserved file again. OpenOptions in src/deno_ral/fs.ts gains createNew for this.

With the reproduction from the issue, a dev build of main failed in 6 of 8 runs, and this branch in 0 of 10, with no transient notebooks left behind. New unit tests in tests/unit/jupyter/transient-notebook.test.ts cover the reservation. tests/smoke/inspect/inspect-cleanup.test.ts, tests/unit/preview-compatibility.test.ts and tests/unit/project/file-information-cache.test.ts pass.

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
  • Codebase grounding: local clone, .claude/rules/, reproduction script from the issue
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

The name of the transient notebook was picked with an existsSync loop,
but the file was only written after an await. A render and a concurrent
`quarto inspect` of the same document (Posit Publisher in Positron runs
inspect on every save) could pick the same name, and the first to finish
removed the notebook the other one was still using, failing the render
with [Errno 2]. Create the file with createNew instead, so each process
gets its own name.
@posit-snyk-bot

posit-snyk-bot commented Nov 13, 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.

Concurrent quarto inspect and quarto render of the same .qmd pick the same .quarto_ipynb and the render fails with [Errno 2]

2 participants