-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test-npm failing on master after introduction of initial async hooks implementation #13045
Comments
I'll try to distill this into a test case. |
Hmmm, this is not new. I debugged this 2-3 times with @trevnorris over the course of Async Hooks' development. I was pretty sure it was fixed, though. |
I've run into this elsewhere. Thought I traced through core code well enough to be confident those checks could be removed, but apparently that's not the case. Only way I've found that can definitely mitigate this issue is to check if the call is actually a function. If someone has a better idea I'm all ears. Otherwise I can write up a PR to fix this. |
@trevnorris what causes the issue? |
@AndreasMadsen from what I've seen it usually happens when users fake the |
I have an almost minimal (depends on 'use strict'
var https = require('https')
var request = require('request')
var opt = {
agent: new https.Agent({
'keepAlive': true,
'maxSockets': 50,
'rejectUnauthorized': true,
}),
uri: 'https://www.google.com/'
}
request(opt, (error, response, data) => {
console.log(`error: ${error}`)
console.log(`response: ${response}`)
console.log(`data.length: ${data && data.length}`)
request(opt, (error, response, data) => {
console.log(`error: ${error}`)
console.log(`response: ${response}`)
console.log(`data.length: ${data && data.length}`)
});
}); Still |
@trevnorris question: in 7e3a3c9 why did only
|
@refack That's not true. Custom async |
Gottcha... 👍 |
minimal failing test'use strict'
var https = require('https')
var options = {
agent: new https.Agent({
'keepAlive': true,
'maxSockets': 50,
'rejectUnauthorized': true,
}),
hostname: 'encrypted.google.com',
port: 443,
path: '/',
method: 'GET'
}
const req = https.request(options, (res) => {
console.log('statusCode:', res.statusCode)
res.on('error', (e) => {
console.error(e)
})
let ret = ''
res.on('data', (d) => { ret += d })
res.socket.on('free', (hadErr) => {
console.log(`hadErr ${hadErr}`)
console.log(`ret.length ${ret.length}`)
const req2 = https.request(options)
})
})
req.end(); Output
IMHO since it's a TLS connection, the Agent tries to reuse a |
When using an Agent for HTTPS, `TLSSocket`s are reused and need to have the ability to `asyncReset` from JS. PR-URL: nodejs#13092 Fixes: nodejs#13045 Reviewed-By: Andreas Madsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
/cc @nodejs/async_hooks |
There was further discussion on the "broken" Agent story in #13548 (comment) |
PR-URL: nodejs#13839 Fixes: nodejs#13045 Fixes: nodejs#13831 Refs: nodejs#13352 Refs: nodejs#13548 (comment) Reviewed-By: Trevor Norris <[email protected]>
PR-URL: nodejs#13839 Fixes: nodejs#13045 Fixes: nodejs#13831 Refs: nodejs#13352 Refs: nodejs#13548 (comment) Reviewed-By: Trevor Norris <[email protected]>
PR-URL: #13839 Fixes: #13045 Fixes: #13831 Refs: #13352 Refs: #13548 (comment) Reviewed-By: Trevor Norris <[email protected]>
PR-URL: #13839 Fixes: #13045 Fixes: #13831 Refs: #13352 Refs: #13548 (comment) Reviewed-By: Trevor Norris <[email protected]>
PR-URL: #13839 Fixes: #13045 Fixes: #13831 Refs: #13352 Refs: #13548 (comment) Reviewed-By: Trevor Norris <[email protected]>
make test-npm
is failing since #12892 (4a7233c) landed it seems. In particular, it appears that it's possible for a socket handle to not have anasyncReset
function attached (perhaps something in npm or one of its dependencies are unsetting it?), causing aTypeError
on this line.After running across that issue, I spotted just a few lines below that that there is a bug waiting to happen on this line and this line because
newSocket
should beundefined
if an error occurred.I have not checked for other similar potential issues yet.
/cc @AndreasMadsen @addaleax @trevnorris
The text was updated successfully, but these errors were encountered: