@jaypie/express 1.2.4-rc15 → 1.2.4-rc17
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 +38 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +38 -7
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -934,6 +934,7 @@ function runExpressApp(app, req, res) {
|
|
|
934
934
|
*/
|
|
935
935
|
function createLambdaHandler(app, _options) {
|
|
936
936
|
return async (event, context) => {
|
|
937
|
+
let result;
|
|
937
938
|
try {
|
|
938
939
|
// Set current invoke for getCurrentInvokeUuid
|
|
939
940
|
setCurrentInvoke(event, context);
|
|
@@ -943,8 +944,38 @@ function createLambdaHandler(app, _options) {
|
|
|
943
944
|
const res = new LambdaResponseBuffered();
|
|
944
945
|
// Run Express app
|
|
945
946
|
await runExpressApp(app, req, res);
|
|
946
|
-
//
|
|
947
|
-
|
|
947
|
+
// Get Lambda response - await explicitly to ensure we have the result
|
|
948
|
+
result = await res.getResult();
|
|
949
|
+
// Debug: Log the response before returning
|
|
950
|
+
console.log("[createLambdaHandler] Returning response:", JSON.stringify({
|
|
951
|
+
statusCode: result.statusCode,
|
|
952
|
+
headers: result.headers,
|
|
953
|
+
bodyLength: result.body?.length,
|
|
954
|
+
isBase64Encoded: result.isBase64Encoded,
|
|
955
|
+
}));
|
|
956
|
+
return result;
|
|
957
|
+
}
|
|
958
|
+
catch (error) {
|
|
959
|
+
// Log any unhandled errors
|
|
960
|
+
console.error("[createLambdaHandler] Unhandled error:", error);
|
|
961
|
+
if (error instanceof Error) {
|
|
962
|
+
console.error("[createLambdaHandler] Stack:", error.stack);
|
|
963
|
+
}
|
|
964
|
+
// Return a proper error response instead of throwing
|
|
965
|
+
return {
|
|
966
|
+
statusCode: 500,
|
|
967
|
+
headers: { "content-type": "application/json" },
|
|
968
|
+
body: JSON.stringify({
|
|
969
|
+
errors: [
|
|
970
|
+
{
|
|
971
|
+
status: 500,
|
|
972
|
+
title: "Internal Server Error",
|
|
973
|
+
detail: error instanceof Error ? error.message : "Unknown error occurred",
|
|
974
|
+
},
|
|
975
|
+
],
|
|
976
|
+
}),
|
|
977
|
+
isBase64Encoded: false,
|
|
978
|
+
};
|
|
948
979
|
}
|
|
949
980
|
finally {
|
|
950
981
|
// Clear current invoke context
|
|
@@ -1796,12 +1827,12 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1796
1827
|
}
|
|
1797
1828
|
}
|
|
1798
1829
|
catch (error) {
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
if (error instanceof Error && error.stack) {
|
|
1803
|
-
log.error(error.stack);
|
|
1830
|
+
// Use console.error for raw stack trace to ensure it appears in CloudWatch
|
|
1831
|
+
if (error instanceof Error) {
|
|
1832
|
+
console.error("Express response error stack trace:", error.stack);
|
|
1804
1833
|
}
|
|
1834
|
+
log.fatal(`Express encountered an error while sending the response: ${error instanceof Error ? error.message : String(error)}`);
|
|
1835
|
+
log.var({ responseError: error });
|
|
1805
1836
|
}
|
|
1806
1837
|
// Log response
|
|
1807
1838
|
const extras = {};
|