@middy/core 4.0.9 → 4.1.0
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/index.cjs +4 -3
- package/index.js +4 -3
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -81,30 +81,31 @@ const middy = (lambdaHandler = defaultLambdaHandler, plugin = {})=>{
|
|
|
81
81
|
return middy;
|
|
82
82
|
};
|
|
83
83
|
const runRequest = async (request, beforeMiddlewares, lambdaHandler, afterMiddlewares, onErrorMiddlewares, plugin)=>{
|
|
84
|
+
let timeoutAbort;
|
|
84
85
|
const timeoutEarly = plugin.timeoutEarly && request.context.getRemainingTimeInMillis;
|
|
85
86
|
try {
|
|
86
87
|
await runMiddlewares(request, beforeMiddlewares, plugin);
|
|
87
88
|
if (typeof request.response === 'undefined') {
|
|
88
89
|
plugin.beforeHandler?.();
|
|
89
90
|
const handlerAbort = new AbortController();
|
|
90
|
-
let timeoutAbort;
|
|
91
91
|
if (timeoutEarly) timeoutAbort = new AbortController();
|
|
92
92
|
request.response = await Promise.race([
|
|
93
93
|
lambdaHandler(request.event, request.context, {
|
|
94
94
|
signal: handlerAbort.signal
|
|
95
95
|
}),
|
|
96
|
-
timeoutEarly ? (0, _promises.setTimeout)(request.context.getRemainingTimeInMillis() - plugin.timeoutEarlyInMillis, {
|
|
96
|
+
timeoutEarly ? (0, _promises.setTimeout)(request.context.getRemainingTimeInMillis() - plugin.timeoutEarlyInMillis, undefined, {
|
|
97
97
|
signal: timeoutAbort.signal
|
|
98
98
|
}).then(()=>{
|
|
99
99
|
handlerAbort.abort();
|
|
100
100
|
return plugin.timeoutEarlyResponse();
|
|
101
101
|
}) : Promise.race([])
|
|
102
102
|
]);
|
|
103
|
-
|
|
103
|
+
timeoutAbort?.abort();
|
|
104
104
|
plugin.afterHandler?.();
|
|
105
105
|
await runMiddlewares(request, afterMiddlewares, plugin);
|
|
106
106
|
}
|
|
107
107
|
} catch (e1) {
|
|
108
|
+
timeoutAbort?.abort();
|
|
108
109
|
request.response = undefined;
|
|
109
110
|
request.error = e1;
|
|
110
111
|
try {
|
package/index.js
CHANGED
|
@@ -73,30 +73,31 @@ const middy = (lambdaHandler = defaultLambdaHandler, plugin = {})=>{
|
|
|
73
73
|
return middy;
|
|
74
74
|
};
|
|
75
75
|
const runRequest = async (request, beforeMiddlewares, lambdaHandler, afterMiddlewares, onErrorMiddlewares, plugin)=>{
|
|
76
|
+
let timeoutAbort;
|
|
76
77
|
const timeoutEarly = plugin.timeoutEarly && request.context.getRemainingTimeInMillis;
|
|
77
78
|
try {
|
|
78
79
|
await runMiddlewares(request, beforeMiddlewares, plugin);
|
|
79
80
|
if (typeof request.response === 'undefined') {
|
|
80
81
|
plugin.beforeHandler?.();
|
|
81
82
|
const handlerAbort = new AbortController();
|
|
82
|
-
let timeoutAbort;
|
|
83
83
|
if (timeoutEarly) timeoutAbort = new AbortController();
|
|
84
84
|
request.response = await Promise.race([
|
|
85
85
|
lambdaHandler(request.event, request.context, {
|
|
86
86
|
signal: handlerAbort.signal
|
|
87
87
|
}),
|
|
88
|
-
timeoutEarly ? setTimeout(request.context.getRemainingTimeInMillis() - plugin.timeoutEarlyInMillis, {
|
|
88
|
+
timeoutEarly ? setTimeout(request.context.getRemainingTimeInMillis() - plugin.timeoutEarlyInMillis, undefined, {
|
|
89
89
|
signal: timeoutAbort.signal
|
|
90
90
|
}).then(()=>{
|
|
91
91
|
handlerAbort.abort();
|
|
92
92
|
return plugin.timeoutEarlyResponse();
|
|
93
93
|
}) : Promise.race([])
|
|
94
94
|
]);
|
|
95
|
-
|
|
95
|
+
timeoutAbort?.abort();
|
|
96
96
|
plugin.afterHandler?.();
|
|
97
97
|
await runMiddlewares(request, afterMiddlewares, plugin);
|
|
98
98
|
}
|
|
99
99
|
} catch (e1) {
|
|
100
|
+
timeoutAbort?.abort();
|
|
100
101
|
request.response = undefined;
|
|
101
102
|
request.error = e1;
|
|
102
103
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/core",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda (core package)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/aws-lambda": "^8.10.76",
|
|
62
62
|
"@types/node": "^18.0.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "c5abbac9280c3a2f30758188233a7b27367901d1"
|
|
65
65
|
}
|