Skip to content

Commit

Permalink
Add test that show missed callback when upgrading
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanperret committed Feb 18, 2024
1 parent ff0fbfb commit b8a0c51
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,34 @@ describe("server", () => {
});
});

it("should execute when message sent during polling upgrade window", (done) => {
const engine = listen({ allowUpgrades: true }, (port) => {
const socket = new ClientSocket(`ws://localhost:${port}`, {
transports: ["polling", "websocket"],
});
let i = 0;
let j = 0;

engine.on("connection", (conn) => {
conn.on("upgrading", () => {
conn.send("a", (transport) => {
i++;
});
});
});
socket.on("open", () => {
socket.on("message", (msg) => {
j++;
});
});

setTimeout(() => {
expect(i).to.be(j);
done();
}, 100);
});
});

it("should execute when message sent (websocket)", (done) => {
const engine = listen({ allowUpgrades: false }, (port) => {
const socket = new ClientSocket(`ws://localhost:${port}`, {
Expand Down

0 comments on commit b8a0c51

Please sign in to comment.