h2lean 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/stream.js +7 -3
  2. package/package.json +1 -1
package/lib/stream.js CHANGED
@@ -106,10 +106,14 @@ class Http2Stream extends EventEmitter {
106
106
  }
107
107
 
108
108
  respond(headers, options) {
109
+ // node only throws here (internal/http2/core.js respond(): `if (this.headersSent)
110
+ // throw new ERR_HTTP2_HEADERS_SENT()`) and does not emit 'error' on the stream --
111
+ // measured on v26.12.1: a second respond() throws ERR_HTTP2_HEADERS_SENT
112
+ // ("Response has already been initiated.") with no 'error' event. An emit here
113
+ // throws out of a stream that has no 'error' listener, which turns the
114
+ // application's own throw into an uncaught exception node never produces.
109
115
  if (this.headersSent) {
110
- const err = errorOf('ERR_HTTP2_HEADERS_SENT', 'stream has already sent HEADERS');
111
- this.emit('error', err);
112
- throw err;
116
+ throw errorOf('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.');
113
117
  }
114
118
  const opts = options || {};
115
119
  // node puts a `date` on every response of this API too: prepareResponseHeadersObject()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h2lean",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Pure-JavaScript HTTP/2 for Node.js — a drop-in node:http2 replacement (server and client, h2c and TLS) with zero dependencies",
5
5
  "main": "index.js",
6
6
  "files": [