@jaypie/express 1.2.11-dev.1 → 1.2.11-dev.3

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.
@@ -990,8 +990,15 @@ class LambdaResponseStreaming extends node_stream.Writable {
990
990
  console.log("[DIAG:LambdaResponseStreaming:_final] Headers not sent, flushing now");
991
991
  this.flushHeaders();
992
992
  }
993
- this._wrappedStream?.end();
994
- callback();
993
+ if (this._wrappedStream) {
994
+ // FIX #178: Write empty chunk to force Lambda to process metadata
995
+ // Without this, 204 responses have no writes and Lambda ignores our statusCode/headers
996
+ console.log("[DIAG:LambdaResponseStreaming:_final] Writing empty chunk for metadata");
997
+ this._wrappedStream.write("");
998
+ this._wrappedStream.end();
999
+ }
1000
+ // Use setImmediate to ensure stream operations complete before callback
1001
+ setImmediate(callback);
995
1002
  }
996
1003
  }
997
1004