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 diff --git a/src/config/defaultOptions.js b/src/config/defaultOptions.js index 6d227cc37..940b12cce 100644 --- a/src/config/defaultOptions.js +++ b/src/config/defaultOptions.js @@ -28,5 +28,5 @@ export default { layersDir: null, dockerReadOnly: true, functionCleanupIdleTimeSeconds: 60, - allowCache: false, + allowCache: true, }