Skip to content

BadResource: Bad resource ID crash during book project preview (SassCache stale Deno KV handle) #14594

@Artmann

Description

@Artmann

Bug description

Running quarto preview on a book project crashes with BadResource: Bad resource ID. The error originates from the Sass cache system backed by Deno KV — SassCache.getFromHash calls kv.get() on a KV handle that has already been closed, so subsequent re-renders of the book's pages fail.

This looks like the same root cause as #13955 (stale SassCache instance with a closed Deno KV handle left in _sassCache), which is closed and marked fixed for milestone v1.9. However I'm still hitting it on Quarto 1.9.38 in a book project, where the crash repeats across multiple chapter/part pages during preview re-render (/recipes/asia/, /recipes/americas/, /recipes/oceania/, …). It may be a regression or a code path the original fix didn't cover (the book config path goes through bookRenderItems / bookProjectConfig / refreshProjectConfig).

Steps to reproduce

  1. Create a Quarto book project (project: { type: book }) with multiple parts/chapters and an HTML format using a theme + custom CSS, e.g.:

    _quarto.yml:

    project:
      type: book
      output-dir: _book
    
    book:
      title: "Chicken and Rice"
      author: "Me"
      chapters:
        - index.qmd
        - part: "Asia"
          chapters:
            - recipes/asia/index.qmd
        - part: "Americas"
          chapters:
            - recipes/americas/index.qmd
    
    format:
      html:
        theme: cosmo
        css: styles.css
  2. Run quarto preview.

  3. Trigger a re-render (edit and save a file, or navigate between pages).

  4. Observe the crash.

Actual behavior

The preview crashes with BadResource: Bad resource ID, repeated for several pages.

ERROR: BadResource: Bad resource ID

Stack trace:
    at bookRenderItems (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:152897:11)
    at eventLoopTick (ext:core/01_core.js:179:7)
    at async Object.bookProjectConfig [as config] (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:152769:23)
    at async projectContext (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:92038:28)
    at async refreshProjectConfig (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:161559:15)
    at async file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:161719:9

ERROR: BadResource: Bad resource ID

Stack trace:
    at Kv.get (ext:deno_kv/01_db.ts:57:34)
    at SassCache.getFromHash (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:80007:39)
    at SassCache.getOrSet (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:80071:37)
    at eventLoopTick (ext:core/01_core.js:179:7)
    at async compileSass (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:87418:19)
    at async resolveSassBundles (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:125147:17)
    at async resolveExtras (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:129811:14)
    at async runPandoc (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:129235:20)
    at async renderPandoc (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:130920:24)
    at async Object.onRender (file:///C:/Users/Artga/AppData/Local/Programs/Quarto/bin/quarto.js:153801:34)

The Kv.get / SassCache.getFromHash / SassCache.getOrSet / compileSass / resolveSassBundles chain is identical to #13955.

Expected behavior

Preview re-renders the book without crashing — the Sass cache should not reuse a SassCache instance whose Deno KV handle has been closed.

Your environment

  • Quarto version: 1.9.38
  • OS: Windows 11 Pro (10.0.26200)
  • Project type: book (HTML + EPUB + PDF formats configured; crash occurs during HTML preview)

Related

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpreviewissues related to the `preview` command

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions