Skip to content

Http2Server.prototype.close Does Not Work as Expected #28214

@anliting

Description

@anliting

node-v12.4.0-linux-x64/bin/node a.js

let
    http2=require('http2'),
    server=http2.createServer()
server.listen(8000,'127.0.0.1',()=>{
    let client=http2.connect('http://127.0.0.1:8000',()=>{
        console.log('listener called')
        server.close(()=>{
            console.log('close')
        })
    })
})

Expected: server.close stops the server from accepting new connections.
Result: console.log('close') never get called.

I aware that HTTP/2 works different to HTTP/1.1. And I can and should call session.close() on every active session to stop them from accepting new requests.

server.close seems also wait until there is no active sessions to call the callback function, which is not mentioned in the documentation.

And, to make there is no active sessions, I must first of all stop the server from accepting new connections.

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