@hono/node-server 1.19.11 → 1.19.12
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.
- package/dist/globals.d.mts +1 -1
- package/dist/globals.d.ts +1 -1
- package/dist/index.js +51 -3
- package/dist/index.mjs +52 -4
- package/dist/listener.js +51 -3
- package/dist/listener.mjs +52 -4
- package/dist/request.d.mts +1 -1
- package/dist/request.d.ts +1 -1
- package/dist/response.d.mts +1 -1
- package/dist/response.d.ts +1 -1
- package/dist/serve-static.d.mts +1 -1
- package/dist/serve-static.d.ts +1 -1
- package/dist/server.js +51 -3
- package/dist/server.mjs +52 -4
- package/dist/types.d.mts +3 -3
- package/dist/types.d.ts +3 -3
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/vercel.js +51 -3
- package/dist/vercel.mjs +52 -4
- package/package.json +1 -1
package/dist/globals.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export {
|
|
2
|
+
export { }
|
package/dist/globals.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export {
|
|
2
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -376,6 +376,50 @@ if (typeof global.crypto === "undefined") {
|
|
|
376
376
|
|
|
377
377
|
// src/listener.ts
|
|
378
378
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
379
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
380
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
381
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
382
|
+
var drainIncoming = (incoming) => {
|
|
383
|
+
const incomingWithDrainState = incoming;
|
|
384
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
388
|
+
if (incoming instanceof import_node_http22.Http2ServerRequest) {
|
|
389
|
+
try {
|
|
390
|
+
;
|
|
391
|
+
incoming.stream?.close?.(import_node_http22.constants.NGHTTP2_NO_ERROR);
|
|
392
|
+
} catch {
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
let bytesRead = 0;
|
|
397
|
+
const cleanup = () => {
|
|
398
|
+
clearTimeout(timer);
|
|
399
|
+
incoming.off("data", onData);
|
|
400
|
+
incoming.off("end", cleanup);
|
|
401
|
+
incoming.off("error", cleanup);
|
|
402
|
+
};
|
|
403
|
+
const forceClose = () => {
|
|
404
|
+
cleanup();
|
|
405
|
+
const socket = incoming.socket;
|
|
406
|
+
if (socket && !socket.destroyed) {
|
|
407
|
+
socket.destroySoon();
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
411
|
+
timer.unref?.();
|
|
412
|
+
const onData = (chunk) => {
|
|
413
|
+
bytesRead += chunk.length;
|
|
414
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
415
|
+
forceClose();
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
incoming.on("data", onData);
|
|
419
|
+
incoming.on("end", cleanup);
|
|
420
|
+
incoming.on("error", cleanup);
|
|
421
|
+
incoming.resume();
|
|
422
|
+
};
|
|
379
423
|
var handleRequestError = () => new Response(null, {
|
|
380
424
|
status: 400
|
|
381
425
|
});
|
|
@@ -547,14 +591,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
547
591
|
setTimeout(() => {
|
|
548
592
|
if (!incomingEnded) {
|
|
549
593
|
setTimeout(() => {
|
|
550
|
-
incoming
|
|
551
|
-
outgoing.destroy();
|
|
594
|
+
drainIncoming(incoming);
|
|
552
595
|
});
|
|
553
596
|
}
|
|
554
597
|
});
|
|
555
598
|
}
|
|
556
599
|
};
|
|
557
600
|
}
|
|
601
|
+
outgoing.on("finish", () => {
|
|
602
|
+
if (!incomingEnded) {
|
|
603
|
+
drainIncoming(incoming);
|
|
604
|
+
}
|
|
605
|
+
});
|
|
558
606
|
}
|
|
559
607
|
outgoing.on("close", () => {
|
|
560
608
|
const abortController = req[abortControllerKey];
|
|
@@ -569,7 +617,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
569
617
|
setTimeout(() => {
|
|
570
618
|
if (!incomingEnded) {
|
|
571
619
|
setTimeout(() => {
|
|
572
|
-
incoming
|
|
620
|
+
drainIncoming(incoming);
|
|
573
621
|
});
|
|
574
622
|
}
|
|
575
623
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createServer as createServerHTTP } from "http";
|
|
3
3
|
|
|
4
4
|
// src/listener.ts
|
|
5
|
-
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
|
|
5
|
+
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
|
|
6
6
|
|
|
7
7
|
// src/request.ts
|
|
8
8
|
import { Http2ServerRequest } from "http2";
|
|
@@ -337,6 +337,50 @@ if (typeof global.crypto === "undefined") {
|
|
|
337
337
|
|
|
338
338
|
// src/listener.ts
|
|
339
339
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
340
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
341
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
342
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
343
|
+
var drainIncoming = (incoming) => {
|
|
344
|
+
const incomingWithDrainState = incoming;
|
|
345
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
349
|
+
if (incoming instanceof Http2ServerRequest2) {
|
|
350
|
+
try {
|
|
351
|
+
;
|
|
352
|
+
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
|
|
353
|
+
} catch {
|
|
354
|
+
}
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
let bytesRead = 0;
|
|
358
|
+
const cleanup = () => {
|
|
359
|
+
clearTimeout(timer);
|
|
360
|
+
incoming.off("data", onData);
|
|
361
|
+
incoming.off("end", cleanup);
|
|
362
|
+
incoming.off("error", cleanup);
|
|
363
|
+
};
|
|
364
|
+
const forceClose = () => {
|
|
365
|
+
cleanup();
|
|
366
|
+
const socket = incoming.socket;
|
|
367
|
+
if (socket && !socket.destroyed) {
|
|
368
|
+
socket.destroySoon();
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
372
|
+
timer.unref?.();
|
|
373
|
+
const onData = (chunk) => {
|
|
374
|
+
bytesRead += chunk.length;
|
|
375
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
376
|
+
forceClose();
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
incoming.on("data", onData);
|
|
380
|
+
incoming.on("end", cleanup);
|
|
381
|
+
incoming.on("error", cleanup);
|
|
382
|
+
incoming.resume();
|
|
383
|
+
};
|
|
340
384
|
var handleRequestError = () => new Response(null, {
|
|
341
385
|
status: 400
|
|
342
386
|
});
|
|
@@ -508,14 +552,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
508
552
|
setTimeout(() => {
|
|
509
553
|
if (!incomingEnded) {
|
|
510
554
|
setTimeout(() => {
|
|
511
|
-
incoming
|
|
512
|
-
outgoing.destroy();
|
|
555
|
+
drainIncoming(incoming);
|
|
513
556
|
});
|
|
514
557
|
}
|
|
515
558
|
});
|
|
516
559
|
}
|
|
517
560
|
};
|
|
518
561
|
}
|
|
562
|
+
outgoing.on("finish", () => {
|
|
563
|
+
if (!incomingEnded) {
|
|
564
|
+
drainIncoming(incoming);
|
|
565
|
+
}
|
|
566
|
+
});
|
|
519
567
|
}
|
|
520
568
|
outgoing.on("close", () => {
|
|
521
569
|
const abortController = req[abortControllerKey];
|
|
@@ -530,7 +578,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
530
578
|
setTimeout(() => {
|
|
531
579
|
if (!incomingEnded) {
|
|
532
580
|
setTimeout(() => {
|
|
533
|
-
incoming
|
|
581
|
+
drainIncoming(incoming);
|
|
534
582
|
});
|
|
535
583
|
}
|
|
536
584
|
});
|
package/dist/listener.js
CHANGED
|
@@ -368,6 +368,50 @@ if (typeof global.crypto === "undefined") {
|
|
|
368
368
|
|
|
369
369
|
// src/listener.ts
|
|
370
370
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
371
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
372
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
373
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
374
|
+
var drainIncoming = (incoming) => {
|
|
375
|
+
const incomingWithDrainState = incoming;
|
|
376
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
380
|
+
if (incoming instanceof import_node_http22.Http2ServerRequest) {
|
|
381
|
+
try {
|
|
382
|
+
;
|
|
383
|
+
incoming.stream?.close?.(import_node_http22.constants.NGHTTP2_NO_ERROR);
|
|
384
|
+
} catch {
|
|
385
|
+
}
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
let bytesRead = 0;
|
|
389
|
+
const cleanup = () => {
|
|
390
|
+
clearTimeout(timer);
|
|
391
|
+
incoming.off("data", onData);
|
|
392
|
+
incoming.off("end", cleanup);
|
|
393
|
+
incoming.off("error", cleanup);
|
|
394
|
+
};
|
|
395
|
+
const forceClose = () => {
|
|
396
|
+
cleanup();
|
|
397
|
+
const socket = incoming.socket;
|
|
398
|
+
if (socket && !socket.destroyed) {
|
|
399
|
+
socket.destroySoon();
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
403
|
+
timer.unref?.();
|
|
404
|
+
const onData = (chunk) => {
|
|
405
|
+
bytesRead += chunk.length;
|
|
406
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
407
|
+
forceClose();
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
incoming.on("data", onData);
|
|
411
|
+
incoming.on("end", cleanup);
|
|
412
|
+
incoming.on("error", cleanup);
|
|
413
|
+
incoming.resume();
|
|
414
|
+
};
|
|
371
415
|
var handleRequestError = () => new Response(null, {
|
|
372
416
|
status: 400
|
|
373
417
|
});
|
|
@@ -539,14 +583,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
539
583
|
setTimeout(() => {
|
|
540
584
|
if (!incomingEnded) {
|
|
541
585
|
setTimeout(() => {
|
|
542
|
-
incoming
|
|
543
|
-
outgoing.destroy();
|
|
586
|
+
drainIncoming(incoming);
|
|
544
587
|
});
|
|
545
588
|
}
|
|
546
589
|
});
|
|
547
590
|
}
|
|
548
591
|
};
|
|
549
592
|
}
|
|
593
|
+
outgoing.on("finish", () => {
|
|
594
|
+
if (!incomingEnded) {
|
|
595
|
+
drainIncoming(incoming);
|
|
596
|
+
}
|
|
597
|
+
});
|
|
550
598
|
}
|
|
551
599
|
outgoing.on("close", () => {
|
|
552
600
|
const abortController = req[abortControllerKey];
|
|
@@ -561,7 +609,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
561
609
|
setTimeout(() => {
|
|
562
610
|
if (!incomingEnded) {
|
|
563
611
|
setTimeout(() => {
|
|
564
|
-
incoming
|
|
612
|
+
drainIncoming(incoming);
|
|
565
613
|
});
|
|
566
614
|
}
|
|
567
615
|
});
|
package/dist/listener.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/listener.ts
|
|
2
|
-
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
|
|
2
|
+
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
|
|
3
3
|
|
|
4
4
|
// src/request.ts
|
|
5
5
|
import { Http2ServerRequest } from "http2";
|
|
@@ -334,6 +334,50 @@ if (typeof global.crypto === "undefined") {
|
|
|
334
334
|
|
|
335
335
|
// src/listener.ts
|
|
336
336
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
337
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
338
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
339
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
340
|
+
var drainIncoming = (incoming) => {
|
|
341
|
+
const incomingWithDrainState = incoming;
|
|
342
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
346
|
+
if (incoming instanceof Http2ServerRequest2) {
|
|
347
|
+
try {
|
|
348
|
+
;
|
|
349
|
+
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
|
|
350
|
+
} catch {
|
|
351
|
+
}
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
let bytesRead = 0;
|
|
355
|
+
const cleanup = () => {
|
|
356
|
+
clearTimeout(timer);
|
|
357
|
+
incoming.off("data", onData);
|
|
358
|
+
incoming.off("end", cleanup);
|
|
359
|
+
incoming.off("error", cleanup);
|
|
360
|
+
};
|
|
361
|
+
const forceClose = () => {
|
|
362
|
+
cleanup();
|
|
363
|
+
const socket = incoming.socket;
|
|
364
|
+
if (socket && !socket.destroyed) {
|
|
365
|
+
socket.destroySoon();
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
369
|
+
timer.unref?.();
|
|
370
|
+
const onData = (chunk) => {
|
|
371
|
+
bytesRead += chunk.length;
|
|
372
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
373
|
+
forceClose();
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
incoming.on("data", onData);
|
|
377
|
+
incoming.on("end", cleanup);
|
|
378
|
+
incoming.on("error", cleanup);
|
|
379
|
+
incoming.resume();
|
|
380
|
+
};
|
|
337
381
|
var handleRequestError = () => new Response(null, {
|
|
338
382
|
status: 400
|
|
339
383
|
});
|
|
@@ -505,14 +549,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
505
549
|
setTimeout(() => {
|
|
506
550
|
if (!incomingEnded) {
|
|
507
551
|
setTimeout(() => {
|
|
508
|
-
incoming
|
|
509
|
-
outgoing.destroy();
|
|
552
|
+
drainIncoming(incoming);
|
|
510
553
|
});
|
|
511
554
|
}
|
|
512
555
|
});
|
|
513
556
|
}
|
|
514
557
|
};
|
|
515
558
|
}
|
|
559
|
+
outgoing.on("finish", () => {
|
|
560
|
+
if (!incomingEnded) {
|
|
561
|
+
drainIncoming(incoming);
|
|
562
|
+
}
|
|
563
|
+
});
|
|
516
564
|
}
|
|
517
565
|
outgoing.on("close", () => {
|
|
518
566
|
const abortController = req[abortControllerKey];
|
|
@@ -527,7 +575,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
527
575
|
setTimeout(() => {
|
|
528
576
|
if (!incomingEnded) {
|
|
529
577
|
setTimeout(() => {
|
|
530
|
-
incoming
|
|
578
|
+
drainIncoming(incoming);
|
|
531
579
|
});
|
|
532
580
|
}
|
|
533
581
|
});
|
package/dist/request.d.mts
CHANGED
|
@@ -22,4 +22,4 @@ declare const abortControllerKey: unique symbol;
|
|
|
22
22
|
declare const getAbortController: unique symbol;
|
|
23
23
|
declare const newRequest: (incoming: IncomingMessage | Http2ServerRequest, defaultHostname?: string) => any;
|
|
24
24
|
|
|
25
|
-
export { GlobalRequest, IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
|
|
25
|
+
export { GlobalRequest, type IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
|
package/dist/request.d.ts
CHANGED
|
@@ -22,4 +22,4 @@ declare const abortControllerKey: unique symbol;
|
|
|
22
22
|
declare const getAbortController: unique symbol;
|
|
23
23
|
declare const newRequest: (incoming: IncomingMessage | Http2ServerRequest, defaultHostname?: string) => any;
|
|
24
24
|
|
|
25
|
-
export { GlobalRequest, IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
|
|
25
|
+
export { GlobalRequest, type IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream };
|
package/dist/response.d.mts
CHANGED
package/dist/response.d.ts
CHANGED
package/dist/serve-static.d.mts
CHANGED
package/dist/serve-static.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -372,6 +372,50 @@ if (typeof global.crypto === "undefined") {
|
|
|
372
372
|
|
|
373
373
|
// src/listener.ts
|
|
374
374
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
375
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
376
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
377
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
378
|
+
var drainIncoming = (incoming) => {
|
|
379
|
+
const incomingWithDrainState = incoming;
|
|
380
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
384
|
+
if (incoming instanceof import_node_http22.Http2ServerRequest) {
|
|
385
|
+
try {
|
|
386
|
+
;
|
|
387
|
+
incoming.stream?.close?.(import_node_http22.constants.NGHTTP2_NO_ERROR);
|
|
388
|
+
} catch {
|
|
389
|
+
}
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
let bytesRead = 0;
|
|
393
|
+
const cleanup = () => {
|
|
394
|
+
clearTimeout(timer);
|
|
395
|
+
incoming.off("data", onData);
|
|
396
|
+
incoming.off("end", cleanup);
|
|
397
|
+
incoming.off("error", cleanup);
|
|
398
|
+
};
|
|
399
|
+
const forceClose = () => {
|
|
400
|
+
cleanup();
|
|
401
|
+
const socket = incoming.socket;
|
|
402
|
+
if (socket && !socket.destroyed) {
|
|
403
|
+
socket.destroySoon();
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
407
|
+
timer.unref?.();
|
|
408
|
+
const onData = (chunk) => {
|
|
409
|
+
bytesRead += chunk.length;
|
|
410
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
411
|
+
forceClose();
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
incoming.on("data", onData);
|
|
415
|
+
incoming.on("end", cleanup);
|
|
416
|
+
incoming.on("error", cleanup);
|
|
417
|
+
incoming.resume();
|
|
418
|
+
};
|
|
375
419
|
var handleRequestError = () => new Response(null, {
|
|
376
420
|
status: 400
|
|
377
421
|
});
|
|
@@ -543,14 +587,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
543
587
|
setTimeout(() => {
|
|
544
588
|
if (!incomingEnded) {
|
|
545
589
|
setTimeout(() => {
|
|
546
|
-
incoming
|
|
547
|
-
outgoing.destroy();
|
|
590
|
+
drainIncoming(incoming);
|
|
548
591
|
});
|
|
549
592
|
}
|
|
550
593
|
});
|
|
551
594
|
}
|
|
552
595
|
};
|
|
553
596
|
}
|
|
597
|
+
outgoing.on("finish", () => {
|
|
598
|
+
if (!incomingEnded) {
|
|
599
|
+
drainIncoming(incoming);
|
|
600
|
+
}
|
|
601
|
+
});
|
|
554
602
|
}
|
|
555
603
|
outgoing.on("close", () => {
|
|
556
604
|
const abortController = req[abortControllerKey];
|
|
@@ -565,7 +613,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
565
613
|
setTimeout(() => {
|
|
566
614
|
if (!incomingEnded) {
|
|
567
615
|
setTimeout(() => {
|
|
568
|
-
incoming
|
|
616
|
+
drainIncoming(incoming);
|
|
569
617
|
});
|
|
570
618
|
}
|
|
571
619
|
});
|
package/dist/server.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createServer as createServerHTTP } from "http";
|
|
3
3
|
|
|
4
4
|
// src/listener.ts
|
|
5
|
-
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
|
|
5
|
+
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
|
|
6
6
|
|
|
7
7
|
// src/request.ts
|
|
8
8
|
import { Http2ServerRequest } from "http2";
|
|
@@ -337,6 +337,50 @@ if (typeof global.crypto === "undefined") {
|
|
|
337
337
|
|
|
338
338
|
// src/listener.ts
|
|
339
339
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
340
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
341
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
342
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
343
|
+
var drainIncoming = (incoming) => {
|
|
344
|
+
const incomingWithDrainState = incoming;
|
|
345
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
349
|
+
if (incoming instanceof Http2ServerRequest2) {
|
|
350
|
+
try {
|
|
351
|
+
;
|
|
352
|
+
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
|
|
353
|
+
} catch {
|
|
354
|
+
}
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
let bytesRead = 0;
|
|
358
|
+
const cleanup = () => {
|
|
359
|
+
clearTimeout(timer);
|
|
360
|
+
incoming.off("data", onData);
|
|
361
|
+
incoming.off("end", cleanup);
|
|
362
|
+
incoming.off("error", cleanup);
|
|
363
|
+
};
|
|
364
|
+
const forceClose = () => {
|
|
365
|
+
cleanup();
|
|
366
|
+
const socket = incoming.socket;
|
|
367
|
+
if (socket && !socket.destroyed) {
|
|
368
|
+
socket.destroySoon();
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
372
|
+
timer.unref?.();
|
|
373
|
+
const onData = (chunk) => {
|
|
374
|
+
bytesRead += chunk.length;
|
|
375
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
376
|
+
forceClose();
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
incoming.on("data", onData);
|
|
380
|
+
incoming.on("end", cleanup);
|
|
381
|
+
incoming.on("error", cleanup);
|
|
382
|
+
incoming.resume();
|
|
383
|
+
};
|
|
340
384
|
var handleRequestError = () => new Response(null, {
|
|
341
385
|
status: 400
|
|
342
386
|
});
|
|
@@ -508,14 +552,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
508
552
|
setTimeout(() => {
|
|
509
553
|
if (!incomingEnded) {
|
|
510
554
|
setTimeout(() => {
|
|
511
|
-
incoming
|
|
512
|
-
outgoing.destroy();
|
|
555
|
+
drainIncoming(incoming);
|
|
513
556
|
});
|
|
514
557
|
}
|
|
515
558
|
});
|
|
516
559
|
}
|
|
517
560
|
};
|
|
518
561
|
}
|
|
562
|
+
outgoing.on("finish", () => {
|
|
563
|
+
if (!incomingEnded) {
|
|
564
|
+
drainIncoming(incoming);
|
|
565
|
+
}
|
|
566
|
+
});
|
|
519
567
|
}
|
|
520
568
|
outgoing.on("close", () => {
|
|
521
569
|
const abortController = req[abortControllerKey];
|
|
@@ -530,7 +578,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
530
578
|
setTimeout(() => {
|
|
531
579
|
if (!incomingEnded) {
|
|
532
580
|
setTimeout(() => {
|
|
533
|
-
incoming
|
|
581
|
+
drainIncoming(incoming);
|
|
534
582
|
});
|
|
535
583
|
}
|
|
536
584
|
});
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse,
|
|
2
|
-
import { Http2ServerRequest, Http2ServerResponse,
|
|
1
|
+
import { IncomingMessage, ServerResponse, ServerOptions as ServerOptions$1, createServer, Server } from 'node:http';
|
|
2
|
+
import { Http2ServerRequest, Http2ServerResponse, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer, Http2Server, Http2SecureServer } from 'node:http2';
|
|
3
3
|
import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https';
|
|
4
4
|
|
|
5
5
|
type HttpBindings = {
|
|
@@ -41,4 +41,4 @@ type Options = {
|
|
|
41
41
|
} & ServerOptions;
|
|
42
42
|
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
|
|
43
43
|
|
|
44
|
-
export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
|
|
44
|
+
export type { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse,
|
|
2
|
-
import { Http2ServerRequest, Http2ServerResponse,
|
|
1
|
+
import { IncomingMessage, ServerResponse, ServerOptions as ServerOptions$1, createServer, Server } from 'node:http';
|
|
2
|
+
import { Http2ServerRequest, Http2ServerResponse, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer, Http2Server, Http2SecureServer } from 'node:http2';
|
|
3
3
|
import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https';
|
|
4
4
|
|
|
5
5
|
type HttpBindings = {
|
|
@@ -41,4 +41,4 @@ type Options = {
|
|
|
41
41
|
} & ServerOptions;
|
|
42
42
|
type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>;
|
|
43
43
|
|
|
44
|
-
export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
|
|
44
|
+
export type { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType };
|
package/dist/utils.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { OutgoingHttpHeaders } from 'node:http';
|
|
|
2
2
|
import { Writable } from 'node:stream';
|
|
3
3
|
|
|
4
4
|
declare function readWithoutBlocking(readPromise: Promise<ReadableStreamReadResult<Uint8Array>>): Promise<ReadableStreamReadResult<Uint8Array> | undefined>;
|
|
5
|
-
declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<
|
|
6
|
-
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<
|
|
5
|
+
declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<undefined>;
|
|
6
|
+
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;
|
|
7
7
|
declare const buildOutgoingHttpHeaders: (headers: Headers | HeadersInit | null | undefined) => OutgoingHttpHeaders;
|
|
8
8
|
|
|
9
9
|
export { buildOutgoingHttpHeaders, readWithoutBlocking, writeFromReadableStream, writeFromReadableStreamDefaultReader };
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { OutgoingHttpHeaders } from 'node:http';
|
|
|
2
2
|
import { Writable } from 'node:stream';
|
|
3
3
|
|
|
4
4
|
declare function readWithoutBlocking(readPromise: Promise<ReadableStreamReadResult<Uint8Array>>): Promise<ReadableStreamReadResult<Uint8Array> | undefined>;
|
|
5
|
-
declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<
|
|
6
|
-
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<
|
|
5
|
+
declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<undefined>;
|
|
6
|
+
declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined;
|
|
7
7
|
declare const buildOutgoingHttpHeaders: (headers: Headers | HeadersInit | null | undefined) => OutgoingHttpHeaders;
|
|
8
8
|
|
|
9
9
|
export { buildOutgoingHttpHeaders, readWithoutBlocking, writeFromReadableStream, writeFromReadableStreamDefaultReader };
|
package/dist/vercel.js
CHANGED
|
@@ -370,6 +370,50 @@ if (typeof global.crypto === "undefined") {
|
|
|
370
370
|
|
|
371
371
|
// src/listener.ts
|
|
372
372
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
373
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
374
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
375
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
376
|
+
var drainIncoming = (incoming) => {
|
|
377
|
+
const incomingWithDrainState = incoming;
|
|
378
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
382
|
+
if (incoming instanceof import_node_http22.Http2ServerRequest) {
|
|
383
|
+
try {
|
|
384
|
+
;
|
|
385
|
+
incoming.stream?.close?.(import_node_http22.constants.NGHTTP2_NO_ERROR);
|
|
386
|
+
} catch {
|
|
387
|
+
}
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
let bytesRead = 0;
|
|
391
|
+
const cleanup = () => {
|
|
392
|
+
clearTimeout(timer);
|
|
393
|
+
incoming.off("data", onData);
|
|
394
|
+
incoming.off("end", cleanup);
|
|
395
|
+
incoming.off("error", cleanup);
|
|
396
|
+
};
|
|
397
|
+
const forceClose = () => {
|
|
398
|
+
cleanup();
|
|
399
|
+
const socket = incoming.socket;
|
|
400
|
+
if (socket && !socket.destroyed) {
|
|
401
|
+
socket.destroySoon();
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
405
|
+
timer.unref?.();
|
|
406
|
+
const onData = (chunk) => {
|
|
407
|
+
bytesRead += chunk.length;
|
|
408
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
409
|
+
forceClose();
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
incoming.on("data", onData);
|
|
413
|
+
incoming.on("end", cleanup);
|
|
414
|
+
incoming.on("error", cleanup);
|
|
415
|
+
incoming.resume();
|
|
416
|
+
};
|
|
373
417
|
var handleRequestError = () => new Response(null, {
|
|
374
418
|
status: 400
|
|
375
419
|
});
|
|
@@ -541,14 +585,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
541
585
|
setTimeout(() => {
|
|
542
586
|
if (!incomingEnded) {
|
|
543
587
|
setTimeout(() => {
|
|
544
|
-
incoming
|
|
545
|
-
outgoing.destroy();
|
|
588
|
+
drainIncoming(incoming);
|
|
546
589
|
});
|
|
547
590
|
}
|
|
548
591
|
});
|
|
549
592
|
}
|
|
550
593
|
};
|
|
551
594
|
}
|
|
595
|
+
outgoing.on("finish", () => {
|
|
596
|
+
if (!incomingEnded) {
|
|
597
|
+
drainIncoming(incoming);
|
|
598
|
+
}
|
|
599
|
+
});
|
|
552
600
|
}
|
|
553
601
|
outgoing.on("close", () => {
|
|
554
602
|
const abortController = req[abortControllerKey];
|
|
@@ -563,7 +611,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
563
611
|
setTimeout(() => {
|
|
564
612
|
if (!incomingEnded) {
|
|
565
613
|
setTimeout(() => {
|
|
566
|
-
incoming
|
|
614
|
+
drainIncoming(incoming);
|
|
567
615
|
});
|
|
568
616
|
}
|
|
569
617
|
});
|
package/dist/vercel.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/listener.ts
|
|
2
|
-
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
|
|
2
|
+
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
|
|
3
3
|
|
|
4
4
|
// src/request.ts
|
|
5
5
|
import { Http2ServerRequest } from "http2";
|
|
@@ -334,6 +334,50 @@ if (typeof global.crypto === "undefined") {
|
|
|
334
334
|
|
|
335
335
|
// src/listener.ts
|
|
336
336
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
337
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
338
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
339
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
340
|
+
var drainIncoming = (incoming) => {
|
|
341
|
+
const incomingWithDrainState = incoming;
|
|
342
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
346
|
+
if (incoming instanceof Http2ServerRequest2) {
|
|
347
|
+
try {
|
|
348
|
+
;
|
|
349
|
+
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
|
|
350
|
+
} catch {
|
|
351
|
+
}
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
let bytesRead = 0;
|
|
355
|
+
const cleanup = () => {
|
|
356
|
+
clearTimeout(timer);
|
|
357
|
+
incoming.off("data", onData);
|
|
358
|
+
incoming.off("end", cleanup);
|
|
359
|
+
incoming.off("error", cleanup);
|
|
360
|
+
};
|
|
361
|
+
const forceClose = () => {
|
|
362
|
+
cleanup();
|
|
363
|
+
const socket = incoming.socket;
|
|
364
|
+
if (socket && !socket.destroyed) {
|
|
365
|
+
socket.destroySoon();
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
369
|
+
timer.unref?.();
|
|
370
|
+
const onData = (chunk) => {
|
|
371
|
+
bytesRead += chunk.length;
|
|
372
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
373
|
+
forceClose();
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
incoming.on("data", onData);
|
|
377
|
+
incoming.on("end", cleanup);
|
|
378
|
+
incoming.on("error", cleanup);
|
|
379
|
+
incoming.resume();
|
|
380
|
+
};
|
|
337
381
|
var handleRequestError = () => new Response(null, {
|
|
338
382
|
status: 400
|
|
339
383
|
});
|
|
@@ -505,14 +549,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
505
549
|
setTimeout(() => {
|
|
506
550
|
if (!incomingEnded) {
|
|
507
551
|
setTimeout(() => {
|
|
508
|
-
incoming
|
|
509
|
-
outgoing.destroy();
|
|
552
|
+
drainIncoming(incoming);
|
|
510
553
|
});
|
|
511
554
|
}
|
|
512
555
|
});
|
|
513
556
|
}
|
|
514
557
|
};
|
|
515
558
|
}
|
|
559
|
+
outgoing.on("finish", () => {
|
|
560
|
+
if (!incomingEnded) {
|
|
561
|
+
drainIncoming(incoming);
|
|
562
|
+
}
|
|
563
|
+
});
|
|
516
564
|
}
|
|
517
565
|
outgoing.on("close", () => {
|
|
518
566
|
const abortController = req[abortControllerKey];
|
|
@@ -527,7 +575,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
527
575
|
setTimeout(() => {
|
|
528
576
|
if (!incomingEnded) {
|
|
529
577
|
setTimeout(() => {
|
|
530
|
-
incoming
|
|
578
|
+
drainIncoming(incoming);
|
|
531
579
|
});
|
|
532
580
|
}
|
|
533
581
|
});
|