Skip to content

fix: improve websocket and watcher cleanup handling #3478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2025

Conversation

productdevbook
Copy link
Member

Summary

  • Add null checks before closing websocket and listener to prevent errors
  • Use listener.close() instead of listener.server.close() for proper cleanup
  • Remove all listeners from watcher before closing to prevent memory leaks

Changes

  • Added conditional checks for websocket and listener existence before closing
  • Fixed listener close method call
  • Added removeAllListeners() call for watcher cleanup
  • Added null check for watcher in close hook

Test plan

  • Verify that the development server starts normally
  • Confirm that websocket connections work as expected
  • Test that the server closes cleanly without errors when stopping
  • Ensure no memory leaks occur during server restarts

- Add null checks before closing websocket and listener
- Use listener.close() instead of listener.server.close()
- Remove all listeners from watcher before closing
- Add null check for watcher in close hook
Copy link

vercel bot commented Jul 24, 2025

@productdevbook is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

pkg-pr-new bot commented Jul 24, 2025

npm i https://pkg.pr.new/@nuxt/content@3478

commit: c08fbde

src/utils/dev.ts Outdated
Comment on lines 219 to 222
if (watcher) {
watcher.removeAllListeners()
watcher.close()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you missed db.close()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, thank you.

@farnabaz farnabaz merged commit 8041807 into nuxt:main Aug 5, 2025
3 of 4 checks passed
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