diff --git a/src/ServerlessOffline.js b/src/ServerlessOffline.js index 764a82ccd..c5ab6cb0e 100644 --- a/src/ServerlessOffline.js +++ b/src/ServerlessOffline.js @@ -291,25 +291,27 @@ export default class ServerlessOffline { const events = service.getAllEventsInFunction(functionKey) - events.forEach((event) => { - const { http, schedule, websocket } = event - - if (http) { - httpEvents.push({ - functionKey, - handler: functionDefinition.handler, - http, - }) - } - - if (schedule) { - scheduleEvents.push({ functionKey, schedule }) - } - - if (websocket) { - webSocketEvents.push({ functionKey, websocket }) - } - }) + if (events) { + events.forEach((event) => { + const { http, schedule, websocket } = event + + if (http) { + httpEvents.push({ + functionKey, + handler: functionDefinition.handler, + http, + }) + } + + if (schedule) { + scheduleEvents.push({ functionKey, schedule }) + } + + if (websocket) { + webSocketEvents.push({ functionKey, websocket }) + } + }) + } }) return {