Skip to content

fix(dev): suppress spurious dist watcher restart on cold start#1308

Merged
danielroe merged 1 commit intomainfrom
perf/restart
May 9, 2026
Merged

fix(dev): suppress spurious dist watcher restart on cold start#1308
danielroe merged 1 commit intomainfrom
perf/restart

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

this fixes a bug with a full cold start (ie no .nuxt dir) where we would always restart 🤦

❯ rm -rf .nuxt
❯ pnpm dev

> nuxt-app@ dev /private/tmp/nuxt-app
> nuxt dev

│                                                                                                                                   07:22:19
●  Nuxt 4.4.4 (with Nitro 2.13.4, Vite 7.3.3 and Vue 3.5.34)
[get-port] Unable to find an available port (tried 3000 on host "localhost"). Using alternative port 3001.                          07:22:19
                                                                                                                                    07:22:20
  ➜ Local:    http://localhost:3001/
  ➜ Network:  use --host to expose

  ➜ DevTools: press Shift + Option + D in the browser (v3.2.4)                                                                      07:22:20

✔ Vite client built in 12ms                                                                                                        07:22:20
✔ Vite server built in 5ms                                                                                                         07:22:20
✔ Nuxt Nitro server built in 289ms                                                                                           nitro 07:22:21
ℹ .nuxt/dist directory has been removed. Restarting Nuxt...                                                                        07:22:21
ℹ Vite server warmed up in 157ms                                                                                                   07:22:21
✘ [ERROR] The build was canceled

ℹ Vite client warmed up in 207ms                                                                                                   07:22:21
  ➜ DevTools: press Shift + Option + D in the browser (v3.2.4)                                                                      07:22:21

✔ Vite client built in 3ms                                                                                                         07:22:21
✔ Vite server built in 3ms                                                                                                         07:22:21
✔ Nuxt Nitro server built in 183ms                                                                                           nitro 07:22:21
ℹ Vite server warmed up in 1ms                                                                                                     07:22:21
ℹ Vite client warmed up in 1ms                                                                                                     07:22:21

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 9, 2026

  • nuxt-cli-playground

    npm i https://pkg.pr.new/create-nuxt@1308
    
    npm i https://pkg.pr.new/nuxi@1308
    
    npm i https://pkg.pr.new/@nuxt/cli@1308
    

commit: d21e28d

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 49069b1d-096a-4f15-be70-3c714c36ce26

📥 Commits

Reviewing files that changed from the base of the PR and between d6b1115 and d21e28d.

📒 Files selected for processing (1)
  • packages/nuxi/src/dev/utils.ts

📝 Walkthrough

Walkthrough

This pull request updates the Nuxt dev server's .nuxt/dist directory watcher in packages/nuxi/src/dev/utils.ts. The "change" event handler now first verifies whether the distDir still exists. If the directory exists, the handler returns immediately without triggering a restart. The debounced restart with the message '.nuxt/dist directory has been removed' only executes after the directory is confirmed removed, preventing spurious restart calls when transient file changes occur within the directory.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: suppressing an unnecessary dist watcher restart during cold starts.
Description check ✅ Passed The description is directly related to the changeset, explaining the bug being fixed and providing reproduction steps and logs demonstrating the issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/restart

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 9, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing perf/restart (d21e28d) with main (d6b1115)

Open in CodSpeed

@danielroe danielroe merged commit 45ed0b4 into main May 9, 2026
19 checks passed
@danielroe danielroe deleted the perf/restart branch May 9, 2026 06:31
@github-actions github-actions Bot mentioned this pull request May 9, 2026
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.

1 participant