fulmine.js 5.18.0 → 5.18.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/request.js +5 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fulmine.js",
3
- "version": "5.18.0",
3
+ "version": "5.18.1",
4
4
  "description": "Drop-in Express 5 replacement on uWebSockets.js. Your existing middleware keeps working.",
5
5
  "main": "src/index.js",
6
6
  "exports": {
package/src/request.js CHANGED
@@ -914,9 +914,11 @@ module.exports = class Request extends LazyReadable {
914
914
  if (this.#responseEnded) {
915
915
  return;
916
916
  }
917
- // ab.slice(0) copies the ArrayBuffer; uWS neuters `ab` after this callback,
918
- // so a Buffer.from(ab) view would corrupt data left in the Readable queue.
919
- const chunk = Buffer.from(ab.slice(0));
917
+ // The bytes are copied because uWS neuters `ab` when this callback returns, and a
918
+ // view of it would corrupt whatever is still queued. Buffer.from over a view rather
919
+ // than ab.slice(0): the slice allocates an ArrayBuffer of its own for every chunk,
920
+ // which on a small body costs several times the copying it is there to do.
921
+ const chunk = Buffer.from(new Uint8Array(ab));
920
922
  const accepted = this.push(chunk);
921
923
  // push() may synchronously end the response via a flowing-mode listener.
922
924
  if (!accepted && !isLast && !this.#responseEnded) {