Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove multiplication of this.#timeout by 1000 #1177

Merged
merged 3 commits into from Jun 1, 2021

Conversation

aliclark
Copy link
Contributor

Description

Remove a multiplication of this.#timeout by 1000

Motivation and Context

The value returned by context.getRemainingTimeMillis() was 1000 times greater than expected, ie. 900000000 not 900000.

It has already been multiplied by 1000 at

DEFAULT_LAMBDA_TIMEOUT) * 1000
so after multiplying it again at
const executionTimeout = performance.now() + this.#timeout * 1000
it was 1000 times greater than expected.

How Has This Been Tested?

The getRemainingTimeMillis (timeout) check in the LambdaFunction test was incorrectly checking that the function returns a value greater than the original timeout instead of less than the original timeout.

After fixing the checks, the test fails as expected:

  ● LambdaFunction › should use default lambda timeout when timeout is not provided

    expect(received).toBeLessThan(expected)

    Expected: < 900000
    Received:   899999999.83861

      156 |     const remainingTime = await lambdaFunction.runHandler()
      157 | 
    > 158 |     expect(remainingTime).toBeLessThan(DEFAULT_LAMBDA_TIMEOUT * 1000)
          |                           ^
      159 | 
      160 |     // result might be flaky/unreliable:
      161 |     // (assmuning handler runs no longer than 1 s)

      at Object.<anonymous> (src/lambda/__tests__/LambdaFunction.test.js:158:27)

Removing the 1000 multiplication the test is passing again.

@aliclark aliclark changed the title Remove multiplication of this.#timeout by 1000 Remove multiplication of this.#timeout by 1000 for context.getRemainingTimeMillis() Feb 15, 2021
Copy link
Collaborator

@pgrzesik pgrzesik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, thank you @aliclark 🙇

@pgrzesik pgrzesik changed the title Remove multiplication of this.#timeout by 1000 for context.getRemainingTimeMillis() fix: Remove multiplication of this.#timeout by 1000 Jun 1, 2021
@pgrzesik pgrzesik merged commit b320b18 into dherault:master Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants