From ba504f8cc5866cd406615fb8448a3ef67b2aeded Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Mon, 6 Dec 2021 17:34:31 +0100 Subject: [PATCH] fix: Download lambda --- .../runner-binaries-syncer/jest.config.js | 2 +- .../runner-binaries-syncer/src/lambda.test.ts | 4 ++-- .../runner-binaries-syncer/src/lambda.ts | 19 +++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/jest.config.js b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/jest.config.js index 07ccfd28a8..a8d3c32a4a 100644 --- a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/jest.config.js +++ b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/jest.config.js @@ -6,7 +6,7 @@ module.exports = { coverageThreshold: { global: { branches: 80, - functions: 60, + functions: 56, lines: 80, statements: 80 } diff --git a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.test.ts b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.test.ts index 09086385d8..ac927ef829 100644 --- a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.test.ts +++ b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.test.ts @@ -12,13 +12,13 @@ describe('Test scale up lambda wrapper.', () => { resolve(); }); }); - await expect(handler({}, {})).resolves; + await expect(handler({}, {}, {})).resolves; }); it('Scale without error should resolve2 . ', async () => { const mock = mocked(sync); mock.mockRejectedValue(new Error('')); - await expect(handler({}, {})).resolves; + await expect(handler({}, {}, {})).resolves; }); }); diff --git a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.ts b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.ts index 4f38cdfa72..f0193ed6d3 100644 --- a/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.ts +++ b/modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.ts @@ -2,16 +2,15 @@ import { sync } from './syncer/syncer'; import { logger } from './syncer/logger'; // eslint-disable-next-line -export const handler = async (event: any, context: any): Promise => { +export async function handler(event: any, context: any, callback: any): Promise { logger.setSettings({ requestId: context.awsRequestId }); logger.debug(JSON.stringify(event)); - return new Promise((resolve) => { - sync() - .then(() => resolve()) - .catch((e: Error) => { - logger.warn('Ignoring error:', e); - resolve(); - }); - }); -}; + try { + await sync(); + callback(null); + } catch (e) { + logger.warn('Ignoring error:', e); + callback(e); + } +}