-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
fix: return correct type from process.send stub #11799
Conversation
The `process.send` stub created by Jest always returns `undefined` but Node actually always returns `boolean` value from `process.send` (see types [1](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7f660501fbf2e57f885cabf9723aa57c8bfe4f47/types/node/process.d.ts#L1268-L1275) and [2](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7f660501fbf2e57f885cabf9723aa57c8bfe4f47/types/node/child_process.d.ts#L447-L449), as well as [Node docs](https://nodejs.org/dist/latest-v14.x/docs/api/process.html#process_process_send_message_sendhandle_options_callback)) By default, it returns `true` and only returns `false` when the IPC message is buffered or the child process had already exited, see [related docs on child_process](https://nodejs.org/dist/latest-v14.x/docs/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback)
@vladar closed on purpose? |
@SimenB No, looks like GitHub autoclosed it because the referenced PR in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks fine to me - mind adding a changelog entry as well?
Done ✅ Let me know if something needs to be changed |
Codecov Report
@@ Coverage Diff @@
## master #11799 +/- ##
=======================================
Coverage 69.04% 69.04%
=======================================
Files 312 312
Lines 16366 16366
Branches 4746 4746
=======================================
Hits 11300 11300
Misses 5039 5039
Partials 27 27
Continue to review full report at Codecov.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
The
process.send
stub created by Jest always returnsundefined
but Node actually always returnsboolean
value fromprocess.send
(see types 1 and 2, as well as Node docs)By default, it returns
true
and only returnsfalse
when the IPC message is buffered or the child process had already exited, see related docs on child_process.Current behavior of Jest stub causes quirks when user code actually checks for returned values (e.g. to implement backpressure for IPC calls)
Test plan
Not sure how to actually test it. I don't see existing tests for this feature in the original PR #5904