forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
async_wrap: return undefined if domain is disposed
v8::MaybeLocal::ToLocalChecked() will abort on an empty handle. AsyncWrap::MakeCallback returns an empty handle if the domain is disposed, but this should not cause the process to abort. So instead return v8::Undefined() and allow the error to be handled normally. PR-URL: nodejs#14722 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
- Loading branch information
1 parent
11a2ca2
commit 64688d8
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const domain = require('domain'); | ||
|
||
// These were picked arbitrarily and are only used to trigger arync_hooks. | ||
const JSStream = process.binding('js_stream').JSStream; | ||
const Socket = require('net').Socket; | ||
|
||
const handle = new JSStream(); | ||
handle.domain = domain.create(); | ||
handle.domain.dispose(); | ||
|
||
handle.close = () => {}; | ||
handle.isAlive = () => { throw new Error(); }; | ||
|
||
const s = new Socket({ handle }); | ||
|
||
// When AsyncWrap::MakeCallback() returned an empty handle the | ||
// MaybeLocal::ToLocalChecked() call caused the process to abort. By returning | ||
// v8::Undefined() it allows the error to propagate to the 'error' event. | ||
s.on('error', common.mustCall((e) => { | ||
assert.strictEqual(e.code, 'EINVAL'); | ||
})); |