- 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();});});
An http2 server inherits from
net.Server, so a user might expect that the behavior ofclose()is the same (and we document it as being the same). However, the following will never call theclose(cb)callback.This is the same code for
netthat works as expected: