Skip to content

Commit 61c7e0d

Browse files
Merge pull request #26 from viamrobotics/copy-config
Do not mutate configs passed to viam provider
2 parents 1a5d9ed + 0f7fe40 commit 61c7e0d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.changeset/ready-clubs-ask.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@viamrobotics/svelte-sdk': patch
3+
---
4+
5+
Do not mutate configs passed to viam provider

src/lib/hooks/robot-clients.svelte.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,22 @@ export const provideRobotClientsContext = (
6565
connectionStatus[partID] ??= MachineConnectionEvent.DISCONNECTED;
6666

6767
try {
68-
await disconnect(partID, config);
68+
const dialConfig = { ...config };
69+
await disconnect(partID, dialConfig);
6970

7071
connectionStatus[partID] = MachineConnectionEvent.CONNECTING;
7172

7273
// Reset the abort signal if it exists
73-
if (config.reconnectAbortSignal !== undefined) {
74-
config.reconnectAbortSignal = {
74+
if (dialConfig.reconnectAbortSignal !== undefined) {
75+
dialConfig.reconnectAbortSignal = {
7576
abort: false,
7677
};
7778
}
7879

79-
config.reconnectMaxAttempts ??= 1e9;
80-
config.reconnectMaxWait ??= 2000;
80+
dialConfig.reconnectMaxAttempts ??= 1e9;
81+
dialConfig.reconnectMaxWait ??= 2000;
8182

82-
const client = await createRobotClient(config);
83+
const client = await createRobotClient(dialConfig);
8384
(client as RobotClient & { partID: string }).partID = partID;
8485
client.on('connectionstatechange', (event) => {
8586
connectionStatus[partID] = (

0 commit comments

Comments
 (0)