serverless-offline 11.0.1 → 11.0.2
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/package.json +2 -2
- package/src/errors/LambdaTimeoutError.js +1 -0
- package/src/errors/index.js +2 -0
- package/src/events/http/HttpServer.js +1 -1
- package/src/events/http/lambda-events/LambdaProxyIntegrationEvent.js +0 -2
- package/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js +0 -2
- package/src/lambda/LambdaFunction.js +15 -16
- package/src/lambda/handler-runner/worker-thread-runner/workerThreadHelper.js +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dedicatedTo": "Blue, a great migrating bird.",
|
|
3
3
|
"name": "serverless-offline",
|
|
4
|
-
"version": "11.0.
|
|
4
|
+
"version": "11.0.2",
|
|
5
5
|
"description": "Emulate AWS λ and API Gateway locally when developing your Serverless project",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@hapi/h2o2": "^10.0.0",
|
|
87
87
|
"@hapi/hapi": "^20.2.2",
|
|
88
88
|
"@serverless/utils": "^6.7.0",
|
|
89
|
-
"aws-sdk": "^2.
|
|
89
|
+
"aws-sdk": "^2.1227.0",
|
|
90
90
|
"boxen": "^7.0.0",
|
|
91
91
|
"chalk": "^5.0.1",
|
|
92
92
|
"execa": "^6.1.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class LambdaTimeoutError extends Error {}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
DEFAULT_LAMBDA_TIMEOUT,
|
|
15
15
|
supportedRuntimes,
|
|
16
16
|
} from '../config/index.js'
|
|
17
|
+
import { LambdaTimeoutError } from '../errors/index.js'
|
|
17
18
|
import { createUniqueId } from '../utils/index.js'
|
|
18
19
|
|
|
19
20
|
const { ceil } = Math
|
|
@@ -40,8 +41,6 @@ export default class LambdaFunction {
|
|
|
40
41
|
|
|
41
42
|
#handler = null
|
|
42
43
|
|
|
43
|
-
#handlerRunDone = false
|
|
44
|
-
|
|
45
44
|
#handlerRunner = null
|
|
46
45
|
|
|
47
46
|
#idleTimeStarted = null
|
|
@@ -281,14 +280,7 @@ export default class LambdaFunction {
|
|
|
281
280
|
async #timeoutAndTerminate() {
|
|
282
281
|
await setTimeoutPromise(this.#timeout)
|
|
283
282
|
|
|
284
|
-
|
|
285
|
-
if (this.#handlerRunDone) {
|
|
286
|
-
return
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
await this.#handlerRunner.cleanup()
|
|
290
|
-
|
|
291
|
-
throw new Error('Lambda timeout.')
|
|
283
|
+
throw new LambdaTimeoutError('Lambda timeout.')
|
|
292
284
|
}
|
|
293
285
|
|
|
294
286
|
async runHandler() {
|
|
@@ -307,14 +299,20 @@ export default class LambdaFunction {
|
|
|
307
299
|
|
|
308
300
|
this.#startExecutionTimer()
|
|
309
301
|
|
|
310
|
-
|
|
302
|
+
let result
|
|
311
303
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
304
|
+
try {
|
|
305
|
+
result = await Promise.race([
|
|
306
|
+
this.#handlerRunner.run(this.#event, context),
|
|
307
|
+
...(this.#noTimeout ? [] : [this.#timeoutAndTerminate()]),
|
|
308
|
+
])
|
|
309
|
+
} catch (err) {
|
|
310
|
+
if (err instanceof LambdaTimeoutError) {
|
|
311
|
+
await this.#handlerRunner.cleanup()
|
|
312
|
+
}
|
|
316
313
|
|
|
317
|
-
|
|
314
|
+
throw err
|
|
315
|
+
}
|
|
318
316
|
|
|
319
317
|
this.#stopExecutionTimer()
|
|
320
318
|
|
|
@@ -330,6 +328,7 @@ export default class LambdaFunction {
|
|
|
330
328
|
}
|
|
331
329
|
|
|
332
330
|
this.#status = 'IDLE'
|
|
331
|
+
|
|
333
332
|
this.#startIdleTimer()
|
|
334
333
|
|
|
335
334
|
return result
|
|
@@ -2,7 +2,7 @@ import { env } from 'node:process'
|
|
|
2
2
|
import { parentPort, workerData } from 'node:worker_threads'
|
|
3
3
|
import InProcessRunner from '../in-process-runner/index.js'
|
|
4
4
|
|
|
5
|
-
const { functionKey, handler, servicePath, timeout
|
|
5
|
+
const { codeDir, functionKey, handler, servicePath, timeout } = workerData
|
|
6
6
|
|
|
7
7
|
const inProcessRunner = new InProcessRunner(
|
|
8
8
|
{
|