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

http2: client does not emit error when connecting to HTTP/1 #16752

Closed
mcollina opened this issue Nov 4, 2017 · 2 comments
Closed

http2: client does not emit error when connecting to HTTP/1 #16752

mcollina opened this issue Nov 4, 2017 · 2 comments
Assignees
Labels
http2 Issues or PRs related to the http2 subsystem.

Comments

@mcollina
Copy link
Member

mcollina commented Nov 4, 2017

  • Version: master, 8.8.1, 9.0.0
  • Platform: all
  • Subsystem: http2

Currently if we connect to a HTTP/1 server using HTTP/2 the session and the stream are not emitting an error.

Here is a test:

'use strict'

const common = require('../common');

if (!common.hasCrypto)
    common.skip('missing crypto');

const assert = require('assert');

const http2 = require('http2');
const http = require('http');
const net = require('net');

const server = http.createServer(handle);

function handle(req, res) {
  common.fail('the http server should not get any request')
}

server.listen(0, function() {
  server.unref();

  {
    const client = http2.connect(`http://localhost:${server.address().port}`);

    client.on('connect', function () {
      console.log('session connect')
    })

    client.on('close', function () {
      console.log('session close')
    })
    client.socket.on('error', console.log)

    const req = client.request({
      ':path': '/',
      ':method': 'GET'
    });

    req.on('abort', function () {
      console.log('abort')
    })

    req.on('streamClosed', (code) => {
      console.log('streamClosed', code);
    });

    req.on('error', common.mustCall((err) => {
      assert(err);
    }));
  }
});
@mcollina
Copy link
Member Author

mcollina commented Nov 4, 2017

@jasnell and myself are already working on this.

@mcollina mcollina added the http2 Issues or PRs related to the http2 subsystem. label Nov 4, 2017
jasnell added a commit to jasnell/node that referenced this issue Nov 12, 2017
@jasnell
Copy link
Member

jasnell commented Dec 18, 2017

Fixed with #17406

@jasnell jasnell closed this as completed Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants