Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/engine.io-client/lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ export class Socket extends SocketWithUpgrade {
constructor(uri?: string, opts?: SocketOptions);
constructor(opts: SocketOptions);
constructor(uri?: string | SocketOptions, opts: SocketOptions = {}) {
const o = typeof uri === "object" ? uri : opts;
const o = typeof uri === "object" ? { ...uri } : { ...opts };

if (
!o.transports ||
Expand Down
8 changes: 8 additions & 0 deletions packages/engine.io-client/test/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ describe("Socket", function () {
});
});

it("should not mutate the options object", () => {
const options = { transports: ["websocket", "polling"] };
const originalTransports = [...options.transports];
const socket = new Socket(options);
expect(options.transports).to.eql(originalTransports);
socket.close();
});

it("throws an error when no transports are available", (done) => {
const socket = new Socket({ transports: [] });
let errorMessage = "";
Expand Down