request/tunnel-agent

Uncaught exception: AssertionError [ERR_ASSERTION]

Opened this issue ยท 8 comments

In function onConnect you use assert.equal(head.length,0).
If assertion fails, it leads to uncaught process exception.
Please process this as an error so than exception is not beign thrown to nowhere.

This problem arises when I use request module and working with bad proxies.

Having same issue while using proxy and "non existing domain" url

const options = {
    uri: url,
    timeout: requestTimeout,
    resolveWithFullResponse: true,
    proxy: `http://${process.env.PROXY_USERNAME}:${process.env.PROXY_PASSWORD}@us.smartproxy.com:10000`
  }

Bumped into exactly the same error in a batch process which killed the whole thing.

pqvst commented

Any way to work around this issue?

process.on('uncaughtException', err => { if (err.name === 'AssertionError') { console.log('Assertion error', err); } });

Only way to avoid this even though it isn't exactly good practice. Alternatively, you could rebuild the tunnel-agent library, but this is a fast solution if you're being lazy.

I ended up with own fix fork: remoteorigin@0907b7b

gsouf commented

Same here:

2020-03-16T16:36:39.613Z   throw new AssertionError(obj);
2020-03-16T16:36:39.615Z   ^
2020-03-16T16:36:39.617Z 
2020-03-16T16:36:39.620Z AssertionError [ERR_ASSERTION]: 3824 == 0
2020-03-16T16:36:39.622Z     at ClientRequest.onConnect (/home/myuser/node_modules/tunnel-agent/index.js:160:14)
2020-03-16T16:36:39.624Z     at Object.onceWrapper (events.js:286:20)
2020-03-16T16:36:39.626Z     at ClientRequest.emit (events.js:198:13)
2020-03-16T16:36:39.628Z     at Socket.socketOnData (_http_client.js:484:11)
2020-03-16T16:36:39.630Z     at Socket.emit (events.js:198:13)
2020-03-16T16:36:39.632Z     at addChunk (_stream_readable.js:288:12)
2020-03-16T16:36:39.634Z     at readableAddChunk (_stream_readable.js:269:11)
2020-03-16T16:36:39.636Z     at Socket.Readable.push (_stream_readable.js:224:10)
2020-03-16T16:36:39.638Z     at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

Fix pending on PR: #51
since Nov 18, 2019

hi is anyone merging this issue? I really need to get it fixed... tnx