Skip to content

@nuxt/content crashes on temporary files created during non-atomic writes #3759

@XenBG

Description

@XenBG

Environment

When running Nuxt dev with @nuxt/content, the server crashes if a temporary file is created in a watched content directory during a write operation.

This commonly occurs with editors and AI tools that use non-atomic writes (create temp file → rename).

Version

v3.9.0

Reproduction

  1. Start dev server:

    npm run dev
  2. Create a temporary file inside a content directory:

    example.md.tmp.153372.1775487281985
    
  3. Dev server crashes with:

ERROR  [unhandledRejection] .1775487281985 files are not supported.

Description

Expected behavior

Temporary/intermediate files (e.g. *.tmp, *.tmp.*) should be ignored by the content watcher and not processed.


Actual behavior

The watcher attempts to parse the file, fails due to unsupported extension, and throws an unhandled rejection that crashes the dev server.


Environment

  • Nuxt: 4.2.1
  • @nuxt/content: 3.9.0
  • Node: 22.16.0
  • OS: Linux Mint 22.2

Suggested fix

Ignore common temporary file patterns or safely skip unsupported files during parsing to avoid unhandled errors.

Additional context

No response

Logs

$ npm run dev

> dev
> nuxt dev

│                                                                                                                                                                                                                                                 6:05:04 PM
●  Nuxt 4.2.1 (with Nitro 2.12.9, Vite 7.3.0 and Vue 3.5.25)
                                                                                                                                                                                                                                                  6:05:05 PM
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

  ➜ DevTools: press Shift + Alt + D in the browser (v3.1.1)                                                                                                                                                                                       6:05:05 PM

✔ Processed 7 collections and 258 files in 725.19ms (258 cached, 0 parsed)                                                                                                                                                         @nuxt/content 6:05:06 PM
ℹ Nuxt Icon server bundle mode is set to local                                                                                                                                                                                                   6:05:07 PM
✔ Components metas parsed in 0.32ms                                                                                                                                                                                                              6:05:08 PM
✔ Vite client built in 50ms                                                                                                                                                                                                                      6:05:08 PM
✔ Vite server built in 61ms                                                                                                                                                                                                                      6:05:08 PM
✔ Nuxt Nitro server built in 2286ms                                                                                                                                                                                                        nitro 6:05:10 PM
ℹ Vite server warmed up in 1ms                                                                                                                                                                                                                   6:05:10 PM
ℹ Vite client warmed up in 2ms                                                                                                                                                                                                                   6:05:10 PM
ℹ File bg/2.services/example.md.tmp.153372.1775487281985 changed on docs_bg collection                                                                                                                                             @nuxt/content 6:05:35 PM

 ERROR  [unhandledRejection] .1775487281985 files are not supported.                                                                                                                                                                              6:05:35 PM

    at transformContent (node_modules/@nuxt/content/dist/module.mjs:1336:11)
    at parse (node_modules/@nuxt/content/dist/module.mjs:1470:33)
    at async FSWatcher.onChange (node_modules/@nuxt/content/dist/module.mjs:1794:25)


  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

  ➜ DevTools: press Shift + Alt + D in the browser (v3.1.1)                                                                                                                                                                                       6:05:37 PM


 WARN  "docs_bg/bg/2.services/example.md.tmp.153372.1775487281985" is ignored because parsing is failed. Error: .1775487281985 files are not supported.                                                                             @nuxt/content 6:05:37 PM


 WARN  "services/bg/2.services/example.md.tmp.153372.1775487281985" is ignored because parsing is failed. Error: .1775487281985 files are not supported.                                                                            @nuxt/content 6:05:37 PM

✔ Processed 7 collections and 260 files in 760.73ms (258 cached, 2 parsed)                                                                                                                                                         @nuxt/content 6:05:37 PM
ℹ Nuxt Icon server bundle mode is set to local                                                                                                                                                                                                   6:05:38 PM
✔ Components metas parsed in 0.34ms                                                                                                                                                                                                              6:05:39 PM
✔ Vite client built in 49ms                                                                                                                                                                                                                      6:05:39 PM
✔ Vite server built in 56ms                                                                                                                                                                                                                      6:05:39 PM
✔ Nuxt Nitro server built in 2228ms                                                                                                                                                                                                        nitro 6:05:41 PM
ℹ Vite server warmed up in 1ms                                                                                                                                                                                                                   6:05:41 PM
ℹ Vite client warmed up in 2ms                                                                                                                                                                                                                   6:05:41 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions