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

Test failures on node v14-v16

joeyparrish opened this issue · comments

I get the following test failure on Linux after fixing the macOS failures in #393 with PR #394

  1) socket cleanup
       should cleanup sockets on ERR_STREAM_PREMATURE_CLOSE (using stream.pipeline):

      Uncaught AssertionError: expected 1 to equal 0
      + expected - actual

      -1
      +0
      
      at Assertion.fail (node_modules/should/cjs/should.js:275:17)
      at Assertion.value (node_modules/should/cjs/should.js:356:19)
      at Timeout._onTimeout (test/socket_cleanup_spec.js:73:33)
      at listOnTimeout (node:internal/timers:557:17)
      at processTimers (node:internal/timers:500:7)

Reverting the fix in PR #392 does not fix this test failure. Same for the fix in PR #394.

I can't tell from the git commit history why this was commented out, but uncommenting this line in the test fixes it:

    stream.pipeline(resp, writable, function(err) {
      err.code.should.eql('ERR_STREAM_PREMATURE_CLOSE')
      // if (err) resp.request.destroy();
    });

@tomas, any insight on that? I'll put up a PR in case that's the right fix. If it's not... I'll need you to figure it out. I'm out of ideas.

I should have mentioned, this failure was on node v16. When I run tests on macOS with node v16 or v14, I get this failure, too. So it's not specific to Linux after all.