From 34e7abc6f8458eafa548311c385055f5ce264646 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 9 Mar 2022 10:33:26 -0500 Subject: [PATCH] fix: remove extraneous `callbackWaitsForEmptyEventLoop` line (#90) `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 46d7620..90d22f9 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([]); }); });