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
Error response: WebSockets request was expected #787
Comments
Makes me wonder whether this issue has always been possible, but just that there's a low likelihood of it occurring. Related: davidje13/superwstest#11 ( @davidje13 - you might be interested? ) |
I suspect this is a different issue to the one I raised (#566), but you do also have that issue (since you are using If you are seeing "WebSockets request was expected", that means a server has successfully started on that port already and is serving responses, but the server is expecting websocket requests. Looking around for that error message, it seems to be related to the built-in debugger (launched by passing My guess is that in the event that Replacing |
Thinking about this some more, I think you are getting the port conflict due to differing hosts:
Since the hosts are different, I think the latter will consider 9229 to be an available port, and when it is chosen you will see this issue (because you end up with more than one server on port 9229; one listening just locally on your machine, and the other listening on the network too). You are seeing this particularly often in your test because as-written, you are actually starting 1,000 concurrent servers in the test, each needing its own port (but with the fix I mentioned above, you would only start a single server, as you intended). So to fully fix it, you should do the fix I mentioned in my comment above and also update your |
I have an almost identical test case to #566 , except in my test I'm iterating over the
await request().get().expect()
1000 times, to test the performance of the endpoint.80% of the time, the tests pass, but occasionally I hit the following issue.
(400 Bad Request)
Has anyone seen this before?
I've tried adding Promise awaits for the handlers in the beforeEach/afterEach, to no avail.
Node: v18.3.0
Express: 4.17.1
Supertest: 6.2.4
TestCase.ts
The text was updated successfully, but these errors were encountered: