`Curl` call wrapped within a Promise makes mocha not finishing test cases.
See original GitHub issueSorry if this is not a right place but I’m looping with a debugger for hours already and I think I am out of ideas of what can be wrong.
tldr; testing with mocha is highly unreliable, usually times out
Longer story
I’m using this package for a long time and first I’d like to thank all the contributors for amazing work you do. Thank you.
Today I decided to update my small library by bumping node-libcurl
to latest version.
I have small regression/integration test and I found most of them (sometimes all) fail after upgrade with no good reason.
I spent hours trying to detect the issue in my code but I’m pretty sure there is some bug in this code.
I’ve made a smallest as possible test to prove that: https://github.com/sznowicki/uptime-check/blob/node-libcurl-2/test/node-libcurl-issue-test.js
In this file you’ll find three test cases: curl pure implementation, curl wrapped in a promise and called in traditional way, same wrapped curl called in async/await way.
While pure implementation always succeeds (also tried placing it last), Promise.then always times out, async/await usually times out but sometimes is surprisingly green (slow though).
To be honest, I don’t have a good idea why this package would cause this behaviour from mocha, but I did try many ways of testing that to exclude other possibilities.
It just feels like something either overrides mocha’s “done/await” checks.
On way of testing was to resolve early, before Curl is involved and this made the tests finishing again (also included in the test cases I posted). And I think this is a very good reason to post this issue here and not in the mocha repo.
If you have any questions, or concerns I promise to be active in this issue.
If I missed something stupid and obvious, I’d like to apologise in advance.
PS: maybe it matters: node v10.2.1
EDIT:
- The mentioned test is all green with node-libcurl@1.3.3
- my system: macOS 10.14.5
- url used in test doesn’t play any role in this, original tests were testing against a real website under my control
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:31 (22 by maintainers)
For those following along by email: the comment above has been updated with a band-aid solution to this bug.
tl;dr: wrap your
resolve
call insetImmediate
.296 days later this has been finally fixed 🎉🥳, for details see the issue above.
The fix is available on the prerelease version
2.1.0-4
, which can be installed with:If everything works correctly, I will release the
2.1.0
version at the start of next week, I will close this issue when I do that.