Skip to content

fix: prevent change listener leak in Vite plugin#110

Merged
viviveevee merged 3 commits intodfinity:mainfrom
q-uint:fix/vite-plugin-watcher-listener-leak
Feb 18, 2026
Merged

fix: prevent change listener leak in Vite plugin#110
viviveevee merged 3 commits intodfinity:mainfrom
q-uint:fix/vite-plugin-watcher-listener-leak

Conversation

@q-uint
Copy link
Copy Markdown
Contributor

@q-uint q-uint commented Feb 18, 2026

Each call to configureServer (e.g. on Vite dev-server restart) added a new change listener without removing the previous one, eventually triggering Node's MaxListenersExceededWarning.

Store a cleanup function in the plugin closure and call it at the start of each configureServer invocation so only one listener is active at a time. Add tests covering registration, cleanup, file filtering, and the disableWatch opt-out.

Ref: #108

Each call to `configureServer` (e.g. on Vite dev-server restart)
added a new `change` listener without removing the previous one,
eventually triggering Node's `MaxListenersExceededWarning`.

Store a cleanup function in the plugin closure and call it at the
start of each `configureServer` invocation so only one listener is
active at a time. Add tests covering registration, cleanup, file
filtering, and the `disableWatch` opt-out.
@q-uint q-uint requested a review from a team as a code owner February 18, 2026 10:07
@q-uint q-uint changed the title fix: prevent change listener leak in Vite plugin (#108) fix: prevent change listener leak in Vite plugin Feb 18, 2026
@viviveevee
Copy link
Copy Markdown
Contributor

LGTM, thank you.

The flake.nix thingy looks unrelated to the actual changes and I don't know if that thing is commonly used. Would you be ok with not including the Nix flake?

@q-uint
Copy link
Copy Markdown
Contributor Author

q-uint commented Feb 18, 2026

You're right, the Nix flake is unrelated. I'll drop it from this PR.

Copy link
Copy Markdown
Contributor

@viviveevee viviveevee left a comment

Choose a reason for hiding this comment

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

Sweet, thanks!

@viviveevee viviveevee merged commit 75ed818 into dfinity:main Feb 18, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants