szmarczak / http2-wrapper

Use HTTP/2 the same way like HTTP/1
MIT License
240 stars 18 forks source link

`session.destroy(error)` should throw if there's no `error` event handler #22

Closed szmarczak closed 5 years ago

szmarczak commented 5 years ago

This is because the Agent class attaches its own error handler.

It should check if someone has attached an additional handler. If they did, don't throw. If they didn't, throw.

session.on('error', error => {
    ...

    if (listenerCount === 0) {
        throw error;
    }
});