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.
src: pass resource object along with InternalMakeCallback
This was an oversight in 9fdb6e6. Fixing this is necessary to make `executionAsyncResource()` work as expected. Refs: nodejs#30959 Fixes: nodejs#32060 PR-URL: nodejs#32063 Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
2130474
commit 787143b
Showing
4 changed files
with
42 additions
and
3 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
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,37 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const { | ||
executionAsyncResource, | ||
executionAsyncId, | ||
createHook, | ||
} = require('async_hooks'); | ||
const http = require('http'); | ||
|
||
const hooked = {}; | ||
createHook({ | ||
init(asyncId, type, triggerAsyncId, resource) { | ||
hooked[asyncId] = resource; | ||
} | ||
}).enable(); | ||
|
||
const server = http.createServer((req, res) => { | ||
res.write('hello'); | ||
setTimeout(() => { | ||
res.end(' world!'); | ||
}, 1000); | ||
}); | ||
|
||
server.listen(0, () => { | ||
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]); | ||
http.get({ port: server.address().port }, (res) => { | ||
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]); | ||
res.on('data', () => { | ||
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]); | ||
}); | ||
res.on('end', () => { | ||
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]); | ||
server.close(); | ||
}); | ||
}); | ||
}); |