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

Clear timeout if promise has already resolves to avoid hanging open handle #123

Closed

Conversation

vietanhtran16
Copy link

@vietanhtran16 vietanhtran16 commented Sep 27, 2023

Checklist

  • yarn run dist:ci passes on my machine
  • I have followed the commit message guidelines, with messages suitable for appearing in the changelog

Description

We are getting error from jest when running it with --detectOpenHandles
image

Atm, the addTimeout is not clearing the timeout when the promise has resolved which is causing this issue

@vietanhtran16
Copy link
Author

Hey @YOU54F could you help me take a look at the failed CIs? I don' think it is related to my changes

@YOU54F
Copy link
Member

YOU54F commented Sep 27, 2023

yeah that’s a bit odd, i’ll trigger a ci run from main and give this a run locally and see what’s happening.

are you seeing the error requiring this change only with certain versions of node or jest? has it previously been okay?

thanks for the change. will probably be tomorrow or most likely Friday i get a change to sort ( got a talk tomorrow afternoon )

@vietanhtran16
Copy link
Author

vietanhtran16 commented Sep 27, 2023

yeah that’s a bit odd, i’ll trigger a ci run from main and give this a run locally and see what’s happening.

are you seeing the error requiring this change only with certain versions of node or jest? has it previously been okay?

thanks for the change. will probably be tomorrow or most likely Friday i get a change to sort ( got a talk tomorrow afternoon )

Thanks for looking into this.

I think this is probably an issue in previous version of jest too. We are on 29.5.0 atm

@vietanhtran16
Copy link
Author

Also it is an issue with the timeout not being cleaned up properly, version of jest actually doesnt matter. It just happened to catch the issue when we were using this

@tsemerad
Copy link
Contributor

@vietanhtran16 @YOU54F I just pushed a pull request that fixes this issue in a different way. I noticed that Jest recommends calling .unref() on timers to prevent open handles, so that's what I added, and it solved the problem for me.
https://github.com/pactflow/pact-msw-adapter/pull/124/files

@YOU54F
Copy link
Member

YOU54F commented Nov 7, 2023

Closing in favour of #124 which is now merged and released, thanks both

@YOU54F YOU54F closed this Nov 7, 2023
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.

3 participants