@jaypie/express 1.2.7 → 1.2.9
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/cjs/index.cjs +26 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +26 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1259,6 +1259,9 @@ var cors_helper = (config) => {
|
|
|
1259
1259
|
else {
|
|
1260
1260
|
// Fallback for non-CorsError errors
|
|
1261
1261
|
res.status(HTTP_CODE_NO_CONTENT);
|
|
1262
|
+
if (typeof res.flushHeaders === "function") {
|
|
1263
|
+
res.flushHeaders();
|
|
1264
|
+
}
|
|
1262
1265
|
res.end();
|
|
1263
1266
|
}
|
|
1264
1267
|
return;
|
|
@@ -1288,8 +1291,14 @@ var cors_helper = (config) => {
|
|
|
1288
1291
|
// Send 204 No Content response and terminate immediately
|
|
1289
1292
|
// This is critical for Lambda streaming - we must end the response
|
|
1290
1293
|
// synchronously to prevent the stream from hanging.
|
|
1294
|
+
// CRITICAL: Flush headers first to initialize the Lambda stream wrapper.
|
|
1295
|
+
// Without this, _wrappedStream may be null when _final() is called,
|
|
1296
|
+
// causing the Lambda response stream to never close.
|
|
1291
1297
|
res.statusCode = HTTP_CODE_NO_CONTENT;
|
|
1292
1298
|
res.setHeader("Content-Length", "0");
|
|
1299
|
+
if (typeof res.flushHeaders === "function") {
|
|
1300
|
+
res.flushHeaders();
|
|
1301
|
+
}
|
|
1293
1302
|
res.end();
|
|
1294
1303
|
});
|
|
1295
1304
|
return;
|
|
@@ -1574,7 +1583,14 @@ function safeSendJson(res, statusCode, data) {
|
|
|
1574
1583
|
return;
|
|
1575
1584
|
}
|
|
1576
1585
|
// Fall back to standard Express methods for real responses
|
|
1577
|
-
res.status(statusCode)
|
|
1586
|
+
res.status(statusCode);
|
|
1587
|
+
// CRITICAL: For Lambda streaming responses, flush headers before send to
|
|
1588
|
+
// initialize the stream wrapper. Check for _responseStream which is unique
|
|
1589
|
+
// to LambdaResponseStreaming (regular Express res doesn't have this).
|
|
1590
|
+
if ("_responseStream" in res && typeof res.flushHeaders === "function") {
|
|
1591
|
+
res.flushHeaders();
|
|
1592
|
+
}
|
|
1593
|
+
res.json(data);
|
|
1578
1594
|
}
|
|
1579
1595
|
/**
|
|
1580
1596
|
* Safely send a response body, avoiding dd-trace interception.
|
|
@@ -1602,11 +1618,18 @@ function safeSend(res, statusCode, body) {
|
|
|
1602
1618
|
return;
|
|
1603
1619
|
}
|
|
1604
1620
|
// Fall back to standard Express methods for real responses
|
|
1621
|
+
res.status(statusCode);
|
|
1622
|
+
// CRITICAL: For Lambda streaming responses, flush headers before send to
|
|
1623
|
+
// initialize the stream wrapper. Check for _responseStream which is unique
|
|
1624
|
+
// to LambdaResponseStreaming (regular Express res doesn't have this).
|
|
1625
|
+
if ("_responseStream" in res && typeof res.flushHeaders === "function") {
|
|
1626
|
+
res.flushHeaders();
|
|
1627
|
+
}
|
|
1605
1628
|
if (body !== undefined) {
|
|
1606
|
-
res.
|
|
1629
|
+
res.send(body);
|
|
1607
1630
|
}
|
|
1608
1631
|
else {
|
|
1609
|
-
res.
|
|
1632
|
+
res.send();
|
|
1610
1633
|
}
|
|
1611
1634
|
}
|
|
1612
1635
|
function expressHandler(handlerOrOptions, optionsOrHandler) {
|