@jaypie/express 1.2.12 → 1.2.13

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/esm/index.js CHANGED
@@ -53,18 +53,21 @@ class LambdaRequest extends Readable {
53
53
  remoteAddress: options.remoteAddress,
54
54
  };
55
55
  this.connection = this.socket;
56
- // Schedule body push for next tick to ensure stream is ready
57
- // This is needed for body parsers that consume the stream
58
- if (this.bodyBuffer && this.bodyBuffer.length > 0) {
59
- process.nextTick(() => {
60
- if (!this.bodyPushed) {
56
+ // Schedule body push for next tick to ensure stream is ready.
57
+ // This is needed for body parsers that consume the stream.
58
+ // CRITICAL: Always schedule the push, even for empty bodies, to ensure
59
+ // the stream emits 'end'. Otherwise, middleware that waits for the request
60
+ // stream to end (like body parsers) will hang forever on GET requests.
61
+ process.nextTick(() => {
62
+ if (!this.bodyPushed) {
63
+ if (this.bodyBuffer && this.bodyBuffer.length > 0) {
61
64
  this.push(this.bodyBuffer);
62
- this.push(null);
63
- this.bodyPushed = true;
64
- this.complete = true;
65
65
  }
66
- });
67
- }
66
+ this.push(null); // Signal end of stream
67
+ this.bodyPushed = true;
68
+ this.complete = true;
69
+ }
70
+ });
68
71
  }
69
72
  //
70
73
  // Readable stream implementation