Very infrequent TypeError: iconv.encodingExists is not a function
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 237
- PR merge metrics
- No merged PRs in 30d
Description
This probably(™️) 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with needle/lib/decoder.js and the failing stack trace, then review the Node 14 test setup and the listed mocking dependencies. Try to reproduce the intermittent error under the reported environment and inspect how iconv-lite is loaded. Done means identifying the cause and documenting or testing a reliable fix for the TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100