-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Investigate Mocking Server not terminating properly #15371
Comments
I've been researching a bit on how to proper terminate mockttp servers and found the following:
Setting { http2: false } seems like it worked for some people. So on our
Even though, I am not sure how to repro the server not terminating, to actually check that this solves it and which other implications has to disable HTTP2. |
Context: A few months back I noticed that sometimes the tests would hang for a few minutes after all the tests are complete. Before and AfterBeforeTest finishes after ~40s AfterTest finishes after ~40s Test runnerWith the old run command, the process does not exit until ~5min mark, even though the tests finish in under a min.
Investigation - HandlesI then updated Investigation - Potential fix?After some investigation I stumbled across this issue httptoolkit/mockttp#83, and attempted the approach in the comment httptoolkit/mockttp#83 (comment) similar to @seaona comment above but that did not resolve the issue. I also tried upgraded mockttp to a newer version, not the latest at the time as I believe it had breaking changes, but that also didn't work. I then implemented the quick fix below and moved on 😆 Test runner - quick fixI then updated With the new run command, the process exits immediately, but the underlying issues is not resolved.
|
There was one other area I looked into, implementing a
|
Hey metamask team - I'm the maintainer of Mockttp, I just found this issue 😄. I can't be sure from a quick skim what the cause is, but note that for httptoolkit/mockttp#83 the reported problems are very HTTP/2 specific, and disabling that does fix everything there, with minimal downside (technically the tests are less representative of real traffic, which is normally HTTP/2, but the semantics should all be identical). The only remaining non-HTTP/2 case discussed at the end is a Jest bug (jestjs/jest#11665) which was fixed in the latest Jest release. If you have a small standalone repro for issues like this with either HTTP/2 or HTTP/1 though, I would really love to see those, that'd be super useful! If you can open a Mockttp issue with anything like that then I'm happy to fix it for you. It's useful to know the specific version of Node you're using here, since these behaviours vary significantly between versions. Unfortunately Node's HTTP/2 module is still a bit rough around the edges with this kind of shutdown handling (in most non-testing cases, people rarely cleanly shutdown active servers - they run forever till the process is actively stopped) so it's whack-a-mole hunting down race conditions here, and more test cases like this are super helpful for that 👍 |
When we initiate a Mocking Server on our e2e, sometimes it is not terminated properly and stays hanging for a couple of minutes.
A workaround has been put in place, but we should investigate the root cause and fix it.
Might be related to our npm dependency
mockttp
The text was updated successfully, but these errors were encountered: