Skip to content

Commit

Permalink
Merge pull request #904 from zapier/pde-5490/exit-on-callback
Browse files Browse the repository at this point in the history
feat(core) - PDE-5490 calling lambda callback doesnt wait for event loop
  • Loading branch information
standielpls authored Oct 31, 2024
2 parents 64a7bba + 6d687d7 commit 12a8699
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/tools/create-lambda-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ const createLambdaHandler = (appRawOrPath) => {
// Wait for all async events to complete before callback returns.
// This is not strictly necessary since this is the default now when
// using the callback; just putting it here to be explicit.
// In some cases, the code hangs and never exits because the event loop is not
// empty, so we can override the default behavior and exit after the app is done.
context.callbackWaitsForEmptyEventLoop = true;
if (event.skipWaitForAsync === true) {
context.callbackWaitsForEmptyEventLoop = false;
}

// replace native Promise with bluebird (works better with domains)
if (!event.calledFromCli || event.calledFromCliInvoke) {
Expand Down Expand Up @@ -271,6 +276,7 @@ const createLambdaHandler = (appRawOrPath) => {
const compiledApp = schemaTools.prepareApp(appRaw);

const input = createInput(compiledApp, event, logger, logBuffer, rpc);

return app(input);
})
.then((output) => {
Expand Down

0 comments on commit 12a8699

Please sign in to comment.