Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/ninety-turtles-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"partysocket": patch
---

fix(partysocket): avoid module-scope random default
18 changes: 18 additions & 0 deletions packages/partysocket/src/tests/module-scope.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @vitest-environment node
*/

import { afterEach, expect, test, vi } from "vitest";

afterEach(() => {
vi.restoreAllMocks();
});

test("does not generate random values while importing the websocket module", async () => {
vi.resetModules();
const random = vi.spyOn(Math, "random");

await import("../ws");

expect(random).not.toHaveBeenCalled();
});
2 changes: 1 addition & 1 deletion packages/partysocket/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export type Options = {

const DEFAULT = {
maxReconnectionDelay: 10000,
minReconnectionDelay: 1000 + Math.random() * 4000,
minReconnectionDelay: 3000,
minUptime: 5000,
reconnectionDelayGrowFactor: 1.3,
connectionTimeout: 4000,
Expand Down
Loading