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
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
The issue with domain._stack may be a red herring and by design, though it seems to be the issue. Either way, it does not seem that this test case should fail.
vardomain=require('domain')varassert=require('assert')varcount=0vard1=domain.create()d1.run(function(){process.nextTick(function(){vard2=domain.create()d2.run(function(){process.nextTick(function(){// THE PROBLEM IS HERE// IT SEEMS domain._stack POPPED THE WRONG DOMAIN// WHICH RESULTS IN THE OUTER CATCH NEVER BEING CALLED// Should this pass?: assert.equal(domain._stack[0], d1)++countthrownewError('test 2')},0)})d2.on('error',function(err){console.log('inner');++countthrowerr;})},0)})d1.on('error',function(err){console.log('outer')++countassert.equal(err.message,'test 2')assert.equal(count,3)console.log('success!')})
The text was updated successfully, but these errors were encountered:
That seems like the expected behavior when you throw from the error listener. From an example from the domains documentation:
d.on('error', function(er) {
// an error occurred somewhere.
// if we throw it now, it will crash the program
// with the normal line number and stack message.
});
And this expected behavior seems an issue.
I would draw an analogy with nested try-catch blocks. Functionality that domains currently provide seems incompatible with exception bubbling. Also throwing any errors (besides bubbling) from an error handler does't need to be fatal since domains stack is not empty.
Any chance for reappraising what should be expected behavior in this case?
FWIW, it looks like it's possible to mimic error bubbling through manual domain management (e.g., .run()). So it seems this is reasonable behavior given the flexibility of the other portions of the domain API. I could argue that requiring this manual domain management makes the domain API more cumbersome, but since it's easily abstracted, I think the additional flexibility is best.
For posterity, if anyone's looking to mimic domain error bubbling, here's my solution:
The issue with domain._stack may be a red herring and by design, though it seems to be the issue. Either way, it does not seem that this test case should fail.
The text was updated successfully, but these errors were encountered: