You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing a rate limiting feature, I've encountered intermittent low level errors in the form of "socket hang up", etc.
What I found to reliably work around this, is to create a supertest agent for a listening(!) HTTP server rather than an ExpressJS app, i.e.
const app = express();
app.get("/", (req, res) => res.send("OK"));
-const superAgent = request(app);+const server = http.createServer(app).listen(0);+const superAgent = request(server);
for (let i = 0; i < 1000; i++) {
await superAgent.get("/").expect(200);
}
Maybe it's possible to do the server.listen(0) on the TestAgent level so it doesn't have to be repeated for every request, and thus sometimes fail (e.g. for port allocation reasons).
The text was updated successfully, but these errors were encountered:
When testing a rate limiting feature, I've encountered intermittent low level errors in the form of "socket hang up", etc.
What I found to reliably work around this, is to create a supertest agent for a listening(!) HTTP server rather than an ExpressJS app, i.e.
Maybe it's possible to do the
server.listen(0)
on the TestAgent level so it doesn't have to be repeated for every request, and thus sometimes fail (e.g. for port allocation reasons).The text was updated successfully, but these errors were encountered: