Skip to content

http2: server.close not behaving like http1 or net #20630

Description

@mcollina
  • Version: 8, 9, 10, master
  • Platform: Mac OS X
  • Subsystem: http2

An http2 server inherits from net.Server, so a user might expect that the behavior of close() is the same (and we document it as being the same). However, the following will never call the close(cb) callback.

'use strict';consthttp2=require('http2');constassert=require('assert');constserver=http2.createServer();letclient;server.listen(0,function(){client=http2.connect(`http://localhost:${server.address().port}`);client.on('connect',function(){console.log('connect');server.close(function(){console.log('the close callback');});});});server.on('session',(s)=>{s.setTimeout(10,function(){console.log('timeout');s.destroy();});});

This is the same code for net that works as expected:

'use strict';constnet=require('net');constassert=require('assert');constserver=net.createServer();letclient;server.listen(0,function(){client=net.connect(server.address().port);client.on('connect',function(){console.log('connect');server.close(function(){console.log('the close callback');});});});server.on('connection',(s)=>{s.setTimeout(10,function(){console.log('timeout');s.destroy();});});

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.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