Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process exits with http2 and redirects #47

Closed
tripodsan opened this issue May 28, 2020 · 4 comments · Fixed by #88
Closed

process exits with http2 and redirects #47

tripodsan opened this issue May 28, 2020 · 4 comments · Fixed by #88
Assignees
Labels
bug Something isn't working released

Comments

@tripodsan
Copy link
Contributor

Description
when fetching content from a http2 server that sends redirects, the process just quits. no error, no trace, nothing.

when forcing http1, it works.

To Reproduce

async function testFetch() {
  const context = fetchAPI.context({
    // httpProtocol: 'http1',
    // httpsProtocols: ['http1'],
  });
  try {
    console.log('fetching....');
    const resp = await context.fetch('https://embed.spotify.com/?uri=spotify:artist:4gzpq5DPGxSnKTe4SA8HAU', {
      redirect: 'follow',
    });
    console.log(resp.ok, resp.status, resp.headers);

    console.log(await resp.text());
  } catch (e) {
    console.error(e);
    throw e;
  } finally {
    await context.disconnectAll();
  }
}

the url above sends the 2 redirects:

$ curl -I "https://embed.spotify.com/?uri=spotify:artist:4gzpq5DPGxSnKTe4SA8HAU"
HTTP/2 302
server: envoy
date: Thu, 28 May 2020 02:00:38 GMT
content-type: text/html
content-length: 154
location: https://open.spotify.com/embed/?uri=spotify:artist:4gzpq5DPGxSnKTe4SA8HAU
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
via: HTTP/2 edgeproxy, 1.1 google
alt-svc: clear

$ curl -I "https://open.spotify.com/embed/?uri=spotify:artist:4gzpq5DPGxSnKTe4SA8HAU"
HTTP/2 301
server: envoy
date: Thu, 28 May 2020 02:00:52 GMT
content-type: text/html
content-length: 178
location: https://open.spotify.com/embed?uri=spotify:artist:4gzpq5DPGxSnKTe4SA8HAU
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
via: HTTP/2 edgeproxy, 1.1 google
alt-svc: clear

$ curl -I "https://open.spotify.com/embed?uri=spotify:artist:4gzpq5DPGxSnKTe4SA8HAU"
HTTP/2 200
server: envoy
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
...
@tripodsan tripodsan added the bug Something isn't working label May 28, 2020
@tripodsan tripodsan changed the title process crashes with http2 and many (2) redirects process crashes with http2 and redirects May 28, 2020
@stefan-guggisberg stefan-guggisberg self-assigned this May 28, 2020
@stefan-guggisberg stefan-guggisberg changed the title process crashes with http2 and redirects process exits with http2 and redirects May 28, 2020
@stefan-guggisberg
Copy link
Contributor

stefan-guggisberg commented May 29, 2020

The problem can be reproduced with any redirected request over HTTP/2. The number of redirects doesn't matter.

Underlying fetch-h2 issue.

stefan-guggisberg added a commit that referenced this issue May 29, 2020
@stefan-guggisberg
Copy link
Contributor

Note: The issue can't be reproduced in a Mocha test. The following test succeeds, probably because Mocha runs the tests in forked child processes.

  it('redirects work (HTTP/2)', async () => {
    const resp = await fetch('https://nghttp2.org/httpbin/absolute-redirect/3', { redirect: 'follow' });
    assert.equal(resp.status, 200);
    assert.equal(resp.httpVersion, 2);
    assert.equal(resp.redirected, true);
  });

@grantila
Copy link

Fixed in 2.5.0

@github-actions
Copy link

github-actions bot commented Dec 9, 2020

🎉 This issue has been resolved in version 1.9.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants