-
Notifications
You must be signed in to change notification settings - Fork 30k
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: #30959 Fixes: #32060 PR-URL: #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
723aa41
commit 6a9cea9
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(); | ||
}); | ||
}); | ||
}); |