forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
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
- Loading branch information
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(); | ||
}); | ||
}); | ||
}); |