You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version: v10.15.1 (almost definitely present in older versions as well though)
Platform: Linux lyra 4.14.97 #1-NixOS SMP Thu Jan 31 07:13:48 UTC 2019 x86_64 GNU/Linux
Subsystem: Domains
Currently, domains execute the error event within the context of the domain that caught the error. I'm not sure if this is entirely intentional; however, this can easily lead to an infinite loop when using a stream within the error handler due to the domains stack growing at the same rate it shrinks, e.g.:
A workaround is to use aDomain.once instead of aDomain.on to watch the error event, but this workaround will only work for a certain class of consumers of domains--that is, cases where the domain is no longer used after the first error occurs.
It's also possible to manually create a new domain and execute the error event handler within that new domain to avoid this issue.
I believe that domain error handlers should not be executed within the same domain that they're handling. However, I'm not sure if that would be considered a breaking change or a bugfix.
Also I'm not sure if there are any other ways to solve this issue and avoid the infinite loop that may not be considered breaking changes?
The text was updated successfully, but these errors were encountered:
Before this change, domains' error handlers would run with the
corresponding domain as the active domain. This creates the
possibility for domains' error handlers to call themselves recursively
if an event emitter created in the error handler emits an error, or if
the error handler throws an error.
This change sets the active domain to be the domain's parent (or null
if the domain for which the error handler is called has no parent) to
prevent that from happening.
Fixes: nodejs#26086
v10.15.1
(almost definitely present in older versions as well though)Linux lyra 4.14.97 #1-NixOS SMP Thu Jan 31 07:13:48 UTC 2019 x86_64 GNU/Linux
Currently, domains execute the
error
event within the context of the domain that caught the error. I'm not sure if this is entirely intentional; however, this can easily lead to an infinite loop when using a stream within the error handler due to the domains stack growing at the same rate it shrinks, e.g.:A workaround is to use
aDomain.once
instead ofaDomain.on
to watch theerror
event, but this workaround will only work for a certain class of consumers of domains--that is, cases where the domain is no longer used after the first error occurs.It's also possible to manually create a new domain and execute the
error
event handler within that new domain to avoid this issue.I believe that domain error handlers should not be executed within the same domain that they're handling. However, I'm not sure if that would be considered a breaking change or a bugfix.
Also I'm not sure if there are any other ways to solve this issue and avoid the infinite loop that may not be considered breaking changes?
The text was updated successfully, but these errors were encountered: