Skip to content

Document error handling in http2 client connect example #16345

Closed
@jsha

Description

@jsha
  • Version: v8.7.0
  • Platform: Linux membrane 4.4.0-97-generic Embeddable concept #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: http2

Steps to reproduce:

Run the below program with node --expose_http2 sample.js

Expected result:

An error with ECONNREFUSED is thrown.

Actual result:

Program exits with no output.

var http2 = require('http2');
try {
  const client = http2.connect('https://localhost:12345');

  const req = client.request({ ':path': '/foo' });

  req.on('response', (headers) => {
    console.log(headers[':status']);
    console.log(headers['date']);
  });

  let data = '';
  req.setEncoding('utf8');
  req.on('data', (d) => data += d);
  req.on('end', () => client.destroy());
  req.on('error', (err) => console.error(err));
  req.end();
} catch(e) {
  console.error(e);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions