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