serverless-offline 11.0.1 → 11.0.3
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 +3 -3
- 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 +32 -33
- 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.3",
|
|
5
5
|
"description": "Emulate AWS λ and API Gateway locally when developing your Serverless project",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -86,9 +86,9 @@
|
|
|
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.1230.0",
|
|
90
90
|
"boxen": "^7.0.0",
|
|
91
|
-
"chalk": "^5.0
|
|
91
|
+
"chalk": "^5.1.0",
|
|
92
92
|
"execa": "^6.1.0",
|
|
93
93
|
"fs-extra": "^10.1.0",
|
|
94
94
|
"java-invoke-local": "0.0.6",
|
|
@@ -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,31 +299,38 @@ export default class LambdaFunction {
|
|
|
307
299
|
|
|
308
300
|
this.#startExecutionTimer()
|
|
309
301
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
this.#
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
)
|
|
329
|
-
|
|
302
|
+
let result
|
|
303
|
+
|
|
304
|
+
try {
|
|
305
|
+
result = await Promise.race([
|
|
306
|
+
this.#handlerRunner.run(this.#event, context),
|
|
307
|
+
...(this.#noTimeout ? [] : [this.#timeoutAndTerminate()]),
|
|
308
|
+
])
|
|
309
|
+
|
|
310
|
+
this.#stopExecutionTimer()
|
|
311
|
+
|
|
312
|
+
// TEMP TODO FIXME find better solution
|
|
313
|
+
if (!this.#handlerRunner.isDockerRunner()) {
|
|
314
|
+
log.notice(
|
|
315
|
+
`(λ: ${
|
|
316
|
+
this.#functionKey
|
|
317
|
+
}) RequestId: ${requestId} Duration: ${this.#executionTimeInMillis().toFixed(
|
|
318
|
+
2,
|
|
319
|
+
)} ms Billed Duration: ${this.#billedExecutionTimeInMillis()} ms`,
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
} catch (err) {
|
|
323
|
+
if (err instanceof LambdaTimeoutError) {
|
|
324
|
+
await this.#handlerRunner.cleanup()
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
throw err
|
|
328
|
+
} finally {
|
|
329
|
+
this.#status = 'IDLE'
|
|
330
|
+
|
|
331
|
+
this.#startIdleTimer()
|
|
330
332
|
}
|
|
331
333
|
|
|
332
|
-
this.#status = 'IDLE'
|
|
333
|
-
this.#startIdleTimer()
|
|
334
|
-
|
|
335
334
|
return result
|
|
336
335
|
}
|
|
337
336
|
}
|
|
@@ -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
|
{
|