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