grantila / fetch-h2

HTTP/1+2 Fetch API client for Node.js
MIT License
336 stars 16 forks source link

Http1 disconnectAll() doesn't work #77

Closed stefan-guggisberg closed 4 years ago

stefan-guggisberg commented 4 years ago

When making an Http1 request followed by disconnectAll() the process doesn't exit.

When running the following snippet the process hangs, i.e. node doesn't exit. It seems like disconnectAll() doesn't unref the socket.

const { fetch, disconnectAll } = require('fetch-h2');

(async function () {
  const resp = await fetch('https://httpbin.org/status/200');
  await disconnectAll();
}());

OTOH, when making an Http2 request, the process exits as expected:

const { fetch, disconnectAll } = require('fetch-h2');

(async function () {
  const resp = await fetch('https://www.nghttp2.org/httpbin/status/200');
  await disconnectAll();
}());
stefan-guggisberg commented 4 years ago

When the body of the response is consumed the process exits as expected, i.e. the following works:

const { fetch, disconnectAll } = require('fetch-h2');

(async function () {
  const resp = await fetch('https://httpbin.org/status/200');
  await resp.arrayBuffer();
  await disconnectAll();
}());

Note that this only applies to HTTP1 requests. HTTP2 requests don't seem to have this problem.

github-actions[bot] commented 4 years ago

:tada: This issue has been resolved in version 2.4.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: