tomas / needle

Nimble, streamable HTTP client for Node.js. With proxy, iconv, cookie, deflate & multipart support.

Home Page:https://www.npmjs.com/package/needle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Very infrequent TypeError: iconv.encodingExists is not a function

FauxFaux opened this issue · comments

This probably(:tm:) isn't a bug in needle, but it appears in needle, so I thought I'd raise it here, just in case someone else is going insane.

Very, very occasionally, we get this error in tests:

TypeError: iconv.encodingExists is not a function
    at StreamDecoder.Object.<anonymous>.StreamDecoder._transform (foo/node_modules/needle/lib/decoder.js:27:17)
    at StreamDecoder.Transform._read (internal/streams/transform.js:205:10)
    at StreamDecoder.Transform._write (internal/streams/transform.js:193:12)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at StreamDecoder.Writable.write (internal/streams/writable.js:303:10)
    at IncomingMessage.ondata (internal/streams/readable.js:731:22)
    at IncomingMessage.emit (events.js:412:35)
    at IncomingMessage.emit (domain.js:475:12)
    at IncomingMessage.Readable.read (internal/streams/readable.js:504:10)
    at flow (internal/streams/readable.js:987:34)
    at resume_ (internal/streams/readable.js:968:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

I am reasonably sure this is impossible.

I have reviewed decoder.js and iconv-lite carefully. needle is loading a modern, compatible version of iconv-lite:

└─┬ needle@3.1.0
  └── iconv-lite@0.6.3 

We're using all kinds of mocking (jest 26, sinon 9, nock 13, etc.), but we have no reason to ever have touched iconv, or needle itself (beyond what nock does), and it's not isolated to any specific test. Node 14, linux.

I'll update here if we get anywhere.