@jaypie/express 1.2.4-rc16 → 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/esm/index.js CHANGED
@@ -932,6 +932,7 @@ function runExpressApp(app, req, res) {
932
932
  */
933
933
  function createLambdaHandler(app, _options) {
934
934
  return async (event, context) => {
935
+ let result;
935
936
  try {
936
937
  // Set current invoke for getCurrentInvokeUuid
937
938
  setCurrentInvoke(event, context);
@@ -941,8 +942,38 @@ function createLambdaHandler(app, _options) {
941
942
  const res = new LambdaResponseBuffered();
942
943
  // Run Express app
943
944
  await runExpressApp(app, req, res);
944
- // Return Lambda response
945
- return res.getResult();
945
+ // Get Lambda response - await explicitly to ensure we have the result
946
+ result = await res.getResult();
947
+ // Debug: Log the response before returning
948
+ console.log("[createLambdaHandler] Returning response:", JSON.stringify({
949
+ statusCode: result.statusCode,
950
+ headers: result.headers,
951
+ bodyLength: result.body?.length,
952
+ isBase64Encoded: result.isBase64Encoded,
953
+ }));
954
+ return result;
955
+ }
956
+ catch (error) {
957
+ // Log any unhandled errors
958
+ console.error("[createLambdaHandler] Unhandled error:", error);
959
+ if (error instanceof Error) {
960
+ console.error("[createLambdaHandler] Stack:", error.stack);
961
+ }
962
+ // Return a proper error response instead of throwing
963
+ return {
964
+ statusCode: 500,
965
+ headers: { "content-type": "application/json" },
966
+ body: JSON.stringify({
967
+ errors: [
968
+ {
969
+ status: 500,
970
+ title: "Internal Server Error",
971
+ detail: error instanceof Error ? error.message : "Unknown error occurred",
972
+ },
973
+ ],
974
+ }),
975
+ isBase64Encoded: false,
976
+ };
946
977
  }
947
978
  finally {
948
979
  // Clear current invoke context