@jaypie/express 1.2.8 → 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/esm/index.js CHANGED
@@ -1583,7 +1583,14 @@ function safeSendJson(res, statusCode, data) {
1583
1583
  return;
1584
1584
  }
1585
1585
  // Fall back to standard Express methods for real responses
1586
- res.status(statusCode).json(data);
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);
1587
1594
  }
1588
1595
  /**
1589
1596
  * Safely send a response body, avoiding dd-trace interception.
@@ -1611,11 +1618,18 @@ function safeSend(res, statusCode, body) {
1611
1618
  return;
1612
1619
  }
1613
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
+ }
1614
1628
  if (body !== undefined) {
1615
- res.status(statusCode).send(body);
1629
+ res.send(body);
1616
1630
  }
1617
1631
  else {
1618
- res.status(statusCode).send();
1632
+ res.send();
1619
1633
  }
1620
1634
  }
1621
1635
  function expressHandler(handlerOrOptions, optionsOrHandler) {