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

test(flaky): fix unresolved promise causing linux failures #6088

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Nov 22, 2024

Problem

#6043
To reproduce, add a 5 second delay to the after hook at the top level.
One way to do this is to insert this at line 84.

after(async function () {
        clock.uninstall()
        await sleep(5000)
    })

Despite asserting that the promise rejects within the test, the promise rejects after the test as well. Not entirely sure why this happening.

  • Tried manually wrapping in try-catch with an await instead of assert.rejects and it still fails.
  • Tried wrapping the promise in another promise before passing to assert.rejects.

Solution

What does appear to work, is manually handling the callback of the promise. That is, explicitly defining a then and catch method to assert the rejection, and awaiting the promise at the end of the test to ensure it resolves before the test finishes. Not sure why this works, but I am unable to reproduce the error with this change.

Notes


License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Hweinstock Hweinstock marked this pull request as ready for review November 22, 2024 17:20
@Hweinstock Hweinstock requested a review from a team as a code owner November 22, 2024 17:20
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.

1 participant