@nxtedition/lib 20.4.0 → 20.4.1

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 (3) hide show
  1. package/http.js +54 -34
  2. package/package.json +1 -1
  3. package/serializers.js +0 -1
package/http.js CHANGED
@@ -181,42 +181,52 @@ export class ServerResponse extends http.ServerResponse {
181
181
  }
182
182
 
183
183
  flushHeaders() {
184
- if (this.#timing.headers === -1) {
185
- this.#timing.headers = performance.now() - this.#now
186
- this.#now += this.#timing.headers
184
+ if (!this.destroyed) {
185
+ if (this.#timing.headers === -1) {
186
+ this.#timing.headers = performance.now() - this.#now
187
+ this.#now += this.#timing.headers
188
+ }
187
189
  }
188
190
  return super.flushHeaders()
189
191
  }
190
192
 
191
193
  write(chunk, encoding, callback) {
192
- if (this.#timing.data === -1) {
193
- this.#timing.data = performance.now() - this.#now
194
- this.#now += this.#timing.data
195
- }
194
+ if (!this.destroyed) {
195
+ if (this.#timing.data === -1) {
196
+ this.#timing.data = performance.now() - this.#now
197
+ this.#now += this.#timing.data
198
+ }
196
199
 
197
- if (this.#timing.headers === -1) {
198
- this.#timing.headers = this.#timing.data
200
+ if (this.#timing.headers === -1) {
201
+ this.#timing.headers = this.#timing.data
202
+ }
199
203
  }
200
204
 
201
205
  return super.write(chunk, encoding, callback)
202
206
  }
203
207
 
204
208
  end(chunk, encoding, callback) {
205
- if (this.#timing.data === -1) {
206
- this.#timing.data = performance.now() - this.#now
207
- this.#now += this.#timing.data
208
- }
209
+ if (!this.destroyed) {
210
+ if (this.#timing.data === -1) {
211
+ this.#timing.data = performance.now() - this.#now
212
+ this.#now += this.#timing.data
213
+ }
209
214
 
210
- if (this.#timing.headers === -1) {
211
- this.#timing.headers = this.#timing.data
215
+ if (this.#timing.headers === -1) {
216
+ this.#timing.headers = this.#timing.data
217
+ }
218
+
219
+ this.#timing.complete = performance.now() - this.#created
212
220
  }
213
221
 
214
222
  return super.end(chunk, encoding, callback)
215
223
  }
216
224
 
217
225
  destroy(err) {
218
- if (this.#timing.complete === -1) {
219
- this.#timing.complete = performance.now() - this.#created
226
+ if (!this.destroyed) {
227
+ if (this.#timing.complete === -1) {
228
+ this.#timing.complete = performance.now() - this.#created
229
+ }
220
230
  }
221
231
 
222
232
  return super.destroy(err)
@@ -246,42 +256,52 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
246
256
  }
247
257
 
248
258
  flushHeaders() {
249
- if (this.#timing.headers === -1) {
250
- this.#timing.headers = performance.now() - this.#now
251
- this.#now += this.#timing.headers
259
+ if (!this.destroyed) {
260
+ if (this.#timing.headers === -1) {
261
+ this.#timing.headers = performance.now() - this.#now
262
+ this.#now += this.#timing.headers
263
+ }
252
264
  }
253
265
  return super.flushHeaders()
254
266
  }
255
267
 
256
268
  write(chunk, encoding, callback) {
257
- if (this.#timing.data === -1) {
258
- this.#timing.data = performance.now() - this.#now
259
- this.#now += this.#timing.data
260
- }
269
+ if (!this.destroyed) {
270
+ if (this.#timing.data === -1) {
271
+ this.#timing.data = performance.now() - this.#now
272
+ this.#now += this.#timing.data
273
+ }
261
274
 
262
- if (this.#timing.headers === -1) {
263
- this.#timing.headers = this.#timing.data
275
+ if (this.#timing.headers === -1) {
276
+ this.#timing.headers = this.#timing.data
277
+ }
264
278
  }
265
279
 
266
280
  return super.write(chunk, encoding, callback)
267
281
  }
268
282
 
269
283
  end(chunk, encoding, callback) {
270
- if (this.#timing.data === -1) {
271
- this.#timing.data = performance.now() - this.#now
272
- this.#now += this.#timing.data
273
- }
284
+ if (!this.destroyed) {
285
+ if (this.#timing.data === -1) {
286
+ this.#timing.data = performance.now() - this.#now
287
+ this.#now += this.#timing.data
288
+ }
274
289
 
275
- if (this.#timing.headers === -1) {
276
- this.#timing.headers = this.#timing.data
290
+ if (this.#timing.headers === -1) {
291
+ this.#timing.headers = this.#timing.data
292
+ }
293
+
294
+ this.#timing.complete = performance.now() - this.#created
277
295
  }
278
296
 
279
297
  return super.end(chunk, encoding, callback)
280
298
  }
281
299
 
282
300
  destroy(err) {
283
- if (this.#timing.complete === -1) {
284
- this.#timing.complete = performance.now() - this.#created
301
+ if (!this.destroyed) {
302
+ if (this.#timing.complete === -1) {
303
+ this.#timing.complete = performance.now() - this.#created
304
+ }
285
305
  }
286
306
 
287
307
  return super.destroy(err)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "20.4.0",
3
+ "version": "20.4.1",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/serializers.js CHANGED
@@ -27,7 +27,6 @@ function getTiming(obj) {
27
27
  return undefined
28
28
  }
29
29
  return {
30
- created: timing.created ?? -1,
31
30
  connect: timing.connect ?? -1,
32
31
  headers: timing.headers ?? -1,
33
32
  data: timing.data ?? -1,