Skip to content

Commit

Permalink
fix randomly failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Jun 20, 2023
1 parent baed014 commit 8fc29d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 0 additions & 4 deletions lib/manager.ts
Expand Up @@ -348,10 +348,6 @@ export class Manager<
const timeout = this._timeout;
debug("connect attempt will timeout after %d", timeout);

if (timeout === 0) {
openSubDestroy(); // prevents a race condition with the 'open' event
}

// set timer
const timer = this.setTimeoutFn(() => {
debug("connect attempt timed out after %d", timeout);
Expand Down
4 changes: 2 additions & 2 deletions test/socket.ts
Expand Up @@ -75,7 +75,7 @@ describe("socket", () => {
const socket = io(BASE_URL, {
forceNew: true,
transports: ["polling"],
timeout: 1,
timeout: 0,
});
socket.on("connect_error", (err) => {
expect(err.message).to.eql("timeout");
Expand All @@ -90,7 +90,7 @@ describe("socket", () => {
const socket = io(BASE_URL, {
forceNew: true,
transports: ["websocket"],
timeout: 1,
timeout: 0,
});
socket.on("connect_error", (err) => {
expect(err.message).to.eql("timeout");
Expand Down
4 changes: 4 additions & 0 deletions test/support/server.ts
Expand Up @@ -5,6 +5,10 @@ export function createServer() {
const server = new Server(3210, {
pingInterval: 2000,
connectionStateRecovery: {},
allowRequest: (req, callback) => {
// add a fixed delay to test the connection timeout on the client side
setTimeout(() => callback(null, true), 10);
},
});

server.of("/foo").on("connection", (socket) => {
Expand Down

0 comments on commit 8fc29d4

Please sign in to comment.