serverless-offline 11.1.0 → 11.1.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dedicatedTo": "Blue, a great migrating bird.",
|
|
3
3
|
"name": "serverless-offline",
|
|
4
|
-
"version": "11.1.
|
|
4
|
+
"version": "11.1.2",
|
|
5
5
|
"description": "Emulate AWS λ and API Gateway locally when developing your Serverless project",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
"@hapi/boom": "^10.0.0",
|
|
86
86
|
"@hapi/h2o2": "^10.0.0",
|
|
87
87
|
"@hapi/hapi": "^20.2.2",
|
|
88
|
-
"@serverless/utils": "^6.
|
|
88
|
+
"@serverless/utils": "^6.8.0",
|
|
89
89
|
"aws-sdk": "^2.1231.0",
|
|
90
90
|
"boxen": "^7.0.0",
|
|
91
|
-
"chalk": "^5.1.
|
|
91
|
+
"chalk": "^5.1.2",
|
|
92
92
|
"execa": "^6.1.0",
|
|
93
93
|
"fs-extra": "^10.1.0",
|
|
94
94
|
"java-invoke-local": "0.0.6",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"mocha": "^10.0.0",
|
|
121
121
|
"nyc": "^15.1.0",
|
|
122
122
|
"prettier": "^2.7.1",
|
|
123
|
-
"serverless": "^3.
|
|
123
|
+
"serverless": "^3.23.0",
|
|
124
124
|
"standard-version": "^9.5.0"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
@@ -9,7 +9,7 @@ export default class ScheduleEventDefinition {
|
|
|
9
9
|
if (typeof rawHttpEventDefinition === 'string') {
|
|
10
10
|
rate = rawHttpEventDefinition
|
|
11
11
|
} else {
|
|
12
|
-
;({
|
|
12
|
+
;({ enabled, rate, ...rest } = rawHttpEventDefinition)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// enabled: true (default)
|
|
@@ -25,9 +25,11 @@ export default class LambdaFunctionPool {
|
|
|
25
25
|
|
|
26
26
|
// NOTE: don't use setInterval, as it would schedule always a new run,
|
|
27
27
|
// regardless of function processing time and e.g. user action (debugging)
|
|
28
|
-
this.#timerRef = setTimeout(() => {
|
|
28
|
+
this.#timerRef = setTimeout(async () => {
|
|
29
|
+
const cleanupWait = []
|
|
30
|
+
|
|
29
31
|
// console.log('run cleanup')
|
|
30
|
-
this.#pool.forEach((lambdaFunctions) => {
|
|
32
|
+
this.#pool.forEach((lambdaFunctions, functionKey) => {
|
|
31
33
|
lambdaFunctions.forEach((lambdaFunction) => {
|
|
32
34
|
const { idleTimeInMillis, status } = lambdaFunction
|
|
33
35
|
|
|
@@ -35,37 +37,43 @@ export default class LambdaFunctionPool {
|
|
|
35
37
|
status === 'IDLE' &&
|
|
36
38
|
idleTimeInMillis >= functionCleanupIdleTimeInMillis
|
|
37
39
|
) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
cleanupWait.push(lambdaFunction.cleanup())
|
|
41
|
+
|
|
40
42
|
lambdaFunctions.delete(lambdaFunction)
|
|
41
43
|
}
|
|
42
44
|
})
|
|
45
|
+
|
|
46
|
+
if (lambdaFunctions.size === 0) {
|
|
47
|
+
this.#pool.delete(functionKey)
|
|
48
|
+
}
|
|
43
49
|
})
|
|
44
50
|
|
|
51
|
+
await Promise.all(cleanupWait)
|
|
52
|
+
|
|
45
53
|
// schedule new timer
|
|
46
54
|
this.#startCleanTimer()
|
|
47
55
|
}, functionCleanupIdleTimeInMillis)
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
#cleanupPool() {
|
|
51
|
-
const
|
|
58
|
+
async #cleanupPool() {
|
|
59
|
+
const cleanupWait = []
|
|
52
60
|
|
|
53
61
|
this.#pool.forEach((lambdaFunctions) => {
|
|
54
62
|
lambdaFunctions.forEach((lambdaFunction) => {
|
|
55
|
-
|
|
56
|
-
wait.push(lambdaFunction.cleanup())
|
|
57
|
-
lambdaFunctions.delete(lambdaFunction)
|
|
63
|
+
cleanupWait.push(lambdaFunction.cleanup())
|
|
58
64
|
})
|
|
59
65
|
})
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
await Promise.all(cleanupWait)
|
|
68
|
+
|
|
69
|
+
this.#pool.clear()
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
// TODO make sure to call this
|
|
65
73
|
async cleanup() {
|
|
66
74
|
clearTimeout(this.#timerRef)
|
|
67
75
|
|
|
68
|
-
|
|
76
|
+
await this.#cleanupPool()
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
get(functionKey, functionDefinition) {
|