From b6268c57ba334021a076f4fa87e48007863b6bba Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 8 Mar 2022 21:16:05 -0500 Subject: [PATCH] Remove extraneous `callbackWaitsForEmptyEventLoop` line `callbackWaitsForEmptyEventLoop` is only needed for non-async functions (i.e. functions that use callbacks) and therefore can be safely removed from this package. See https://github.com/probot/adapter-aws-lambda-serverless/issues/78#issuecomment-1062256878 for more details --- lambda-function.js | 3 --- test/index.test.js | 16 ---------------- 2 files changed, 19 deletions(-) diff --git a/lambda-function.js b/lambda-function.js index f4067c6..0dc8315 100644 --- a/lambda-function.js +++ b/lambda-function.js @@ -4,9 +4,6 @@ const lowercaseKeys = require("lowercase-keys"); async function lambdaFunction(probot, event, context) { try { - // Ends function immediately after callback - context.callbackWaitsForEmptyEventLoop = false; - // lowercase all headers to respect headers insensitivity (RFC 7230 $3.2 'Header Fields', see issue #62) const headersLowerCase = lowercaseKeys(event.headers); diff --git a/test/index.test.js b/test/index.test.js index fdeb166..830700b 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -51,10 +51,6 @@ describe("@probot/adapter-aws-lambda-serverless", () => { await fn(event, context); - expect(context).toStrictEqual({ - callbackWaitsForEmptyEventLoop: false, - }); - expect(mock.activeMocks()).toStrictEqual([]); }); @@ -88,10 +84,6 @@ describe("@probot/adapter-aws-lambda-serverless", () => { await fn(event, context); - expect(context).toStrictEqual({ - callbackWaitsForEmptyEventLoop: false, - }); - expect(mock.activeMocks()).toStrictEqual([]); }); @@ -125,10 +117,6 @@ describe("@probot/adapter-aws-lambda-serverless", () => { await fn(event, context); - expect(context).toStrictEqual({ - callbackWaitsForEmptyEventLoop: false, - }); - expect(mock.activeMocks()).toStrictEqual([]); }); @@ -162,10 +150,6 @@ describe("@probot/adapter-aws-lambda-serverless", () => { await fn(event, context); - expect(context).toStrictEqual({ - callbackWaitsForEmptyEventLoop: false, - }); - expect(mock.activeMocks()).toStrictEqual([]); }); });