@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.
@@ -1585,7 +1585,14 @@ function safeSendJson(res, statusCode, data) {
1585
1585
  return;
1586
1586
  }
1587
1587
  // Fall back to standard Express methods for real responses
1588
- res.status(statusCode).json(data);
1588
+ res.status(statusCode);
1589
+ // CRITICAL: For Lambda streaming responses, flush headers before send to
1590
+ // initialize the stream wrapper. Check for _responseStream which is unique
1591
+ // to LambdaResponseStreaming (regular Express res doesn't have this).
1592
+ if ("_responseStream" in res && typeof res.flushHeaders === "function") {
1593
+ res.flushHeaders();
1594
+ }
1595
+ res.json(data);
1589
1596
  }
1590
1597
  /**
1591
1598
  * Safely send a response body, avoiding dd-trace interception.
@@ -1613,11 +1620,18 @@ function safeSend(res, statusCode, body) {
1613
1620
  return;
1614
1621
  }
1615
1622
  // Fall back to standard Express methods for real responses
1623
+ res.status(statusCode);
1624
+ // CRITICAL: For Lambda streaming responses, flush headers before send to
1625
+ // initialize the stream wrapper. Check for _responseStream which is unique
1626
+ // to LambdaResponseStreaming (regular Express res doesn't have this).
1627
+ if ("_responseStream" in res && typeof res.flushHeaders === "function") {
1628
+ res.flushHeaders();
1629
+ }
1616
1630
  if (body !== undefined) {
1617
- res.status(statusCode).send(body);
1631
+ res.send(body);
1618
1632
  }
1619
1633
  else {
1620
- res.status(statusCode).send();
1634
+ res.send();
1621
1635
  }
1622
1636
  }
1623
1637
  function expressHandler(handlerOrOptions, optionsOrHandler) {