From b0cdb37b5010e4d0152cc1400867dd48989843f1 Mon Sep 17 00:00:00 2001 From: Matthew Kelch Date: Fri, 4 Sep 2020 19:36:50 -0400 Subject: [PATCH 1/3] Hook webpack:compile:watch:compile to forcibly cleanup lambda functions --- src/ServerlessOffline.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ServerlessOffline.js b/src/ServerlessOffline.js index 6aad6cf14..f3da5aeb4 100644 --- a/src/ServerlessOffline.js +++ b/src/ServerlessOffline.js @@ -47,6 +47,7 @@ export default class ServerlessOffline { 'offline:start:ready': this.ready.bind(this), 'offline:start': this._startWithExplicitEnd.bind(this), 'offline:start:end': this.end.bind(this), + 'after:webpack:compile:watch:compile': this.cleanup.bind(this), } } @@ -136,6 +137,17 @@ export default class ServerlessOffline { } } + // Force cleanup lambda functions + async cleanup() { + const eventModules = [] + + if (this.#lambda) { + serverlessLog('Forcing cleanup of Lambda functions') + eventModules.push(this.#lambda.cleanup()) + } + await Promise.all(eventModules) + } + /** * Entry point for the plugin (sls offline) when running 'sls offline' * The call to this.end() would terminate the process before 'offline:start:end' could be consumed From 47e69d09237504d50b5516ba7ab38729f5b95954 Mon Sep 17 00:00:00 2001 From: Matthew Kelch Date: Fri, 4 Sep 2020 20:20:42 -0400 Subject: [PATCH 2/3] Update default options - Enable cache by default - Enable worker threads on node v11.7.0 and higher --- src/config/defaultOptions.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config/defaultOptions.js b/src/config/defaultOptions.js index 6d227cc37..55df21d52 100644 --- a/src/config/defaultOptions.js +++ b/src/config/defaultOptions.js @@ -28,5 +28,11 @@ export default { layersDir: null, dockerReadOnly: true, functionCleanupIdleTimeSeconds: 60, - allowCache: false, + allowCache: true, + // Overrides for node versions >= v11.7.0 + ...(process.version >= 'v11.7.0' + ? { + useWorkerThreads: true, + } + : {}), } From c8893a2443c49d453aa3680f681e20a670cb3876 Mon Sep 17 00:00:00 2001 From: Matthew Kelch Date: Sat, 5 Sep 2020 14:31:37 -0400 Subject: [PATCH 3/3] Revert change to default useWorkerThreads option. --- src/config/defaultOptions.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/config/defaultOptions.js b/src/config/defaultOptions.js index 55df21d52..940b12cce 100644 --- a/src/config/defaultOptions.js +++ b/src/config/defaultOptions.js @@ -29,10 +29,4 @@ export default { dockerReadOnly: true, functionCleanupIdleTimeSeconds: 60, allowCache: true, - // Overrides for node versions >= v11.7.0 - ...(process.version >= 'v11.7.0' - ? { - useWorkerThreads: true, - } - : {}), }