link-check icon indicating copy to clipboard operation
link-check copied to clipboard

Uncaught asynchronous error from needle

Open edwardsph opened this issue 3 years ago • 3 comments

There is a problem with an uncaught asynchronous error in the needle library which crashes the whole node process. Your library is doing just what I need for checking many links but this problem makes it impossible to use unfortunately. Unless needle is fixed, I suspect you may need to look for an alternative as I can't find a way to catch this error, even in your code.

I have also created an issue for needle: https://github.com/tomas/needle/issues/410

Example URL: https://wayback.archive-it.org/3259/20160318141818/http://www.arc.gov/research/MapsofAppalachia.asp?MAP_ID=11 Header: content-type: text/html; charset=maccentraleurope

.../node_modules/needle/node_modules/iconv-lite/lib/index.js:104
                throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')");
                ^

Error: Encoding not recognized: 'maccentraleurope' (searched as: 'maccentraleurope')
    at Object.getCodec (.../node_modules/needle/node_modules/iconv-lite/lib/index.js:104:23)
    at Object.getDecoder (.../node_modules/needle/node_modules/iconv-lite/lib/index.js:125:23)
    at Object.decodeStream (.../node_modules/needle/node_modules/iconv-lite/lib/index.js:156:55)
    at StreamDecoder._transform (.../node_modules/needle/lib/decoder.js:39:26)
    at StreamDecoder.Transform._read (_stream_transform.js:190:10)
    at StreamDecoder.Transform._write (_stream_transform.js:178:12)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at StreamDecoder.Writable.write (_stream_writable.js:299:11)
    at IncomingMessage.ondata (_stream_readable.js:710:20)
    at IncomingMessage.emit (events.js:203:15)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at IncomingMessage.Readable.push (_stream_readable.js:224:10)
    at HTTPParser.parserOnBody (_http_common.js:124:22)
    at TLSSocket.socketOnData (_http_client.js:451:20)
    at TLSSocket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

edwardsph avatar Aug 15 '22 08:08 edwardsph

Still waiting on the next needle release. The pull request was merged after the last release... image

tcort avatar Mar 09 '23 21:03 tcort

Is this outdated and fixed?

dklimpel avatar Mar 11 '24 21:03 dklimpel

I haven't had an opportunity to test this but it looks like the underlying problem was fixed in >[email protected] which was included in https://github.com/tcort/link-check/commit/9d1f24f3b1bcddd95a27fb5e54eed5e4c9c76609. So the 5.3.0 release 2 days ago should be good.

edwardsph avatar Mar 12 '24 08:03 edwardsph