worker: don't leak watch messages to listeners - #65049
Open
bitpshr wants to merge 1 commit into
Open
Conversation
Under `node --watch`, each worker reports its module dependencies to the
watch supervisor over the worker's message channel. The main thread
forwarded those `watch:require` and `watch:import` messages to the
supervisor but then still emitted them to user `worker.on('message')`
listeners, so applications received undocumented internal messages.
Consume the forwarded watch dependency messages instead of surfacing
them to user listeners.
Fixes: nodejs#65044
Signed-off-by: Paul Bouchon <mail@bitpshr.net>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65049 +/- ##
==========================================
+ Coverage 90.15% 90.28% +0.13%
==========================================
Files 744 759 +15
Lines 242517 247637 +5120
Branches 45688 46693 +1005
==========================================
+ Hits 218642 223585 +4943
- Misses 15358 15509 +151
- Partials 8517 8543 +26
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Under
node --watch, each worker reports its module dependencies to the watch supervisor over the worker's message channel. The main thread forwarded thosewatch:require/watch:importmessages to the supervisor but then still emitted them to userworker.on('message')listeners, so applications received undocumented internal messages. It reproduces withnode --watchon a script that spawns aWorker(even an empty one).This consumes the forwarded watch dependency messages instead of surfacing them to user listeners. The main process's own dependency reports go through a separate
process.sendpath in the loader, so watch tracking is unaffected.The added regression test fails before the change (the
watch:requiremessages reach the user listener) and passes after.Fixes: #65044