Unverified Commit 51b14409 authored by Josh Story's avatar Josh Story Committed by GitHub

Fix reentrancy of unhandledRejection filtering (#83741)

Node's internal implementation of process.removeAllListeners calls
process.removeListener internally. The simple patching method originally
tried does not account for this which can lead to listeners not being
removed from the actual process event emitter.

To fix this I modeled the patch as explicitly not allowing sync
reentrancy. You can never call a patched function from inside the
execution of another because we bypass it by setting a flag during patch
execution.

Because of this I also removed the calls to original*() methods while
installing and uninstalling the patch. These can be done using the
regular process methods before and after installation/uninstallation
respectively. This was done to avoid needing to manually scope the
bypass which would have been fine but is a bit more convoluted and its
easier to just use the true underlying methods in the right temporal
scope

I also removed an unecessary rejectionHandled handler because we not
longer use catch on the underlying promise and thus do not create any
new handled rejections.

I also added unit tests
parent 99e09714
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment