Skip to content

Commit 31e942f

Browse files
authored
[node] Upgrade undici and remove ErrorRecordingDispatcher for websockets (powersync-ja#652)
1 parent 3590864 commit 31e942f

File tree

6 files changed

+779
-523
lines changed

6 files changed

+779
-523
lines changed

.changeset/lazy-onions-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/node': minor
3+
---
4+
5+
Upgrade undici and use the default undici errors for WebSockets.

demos/example-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@powersync/node": "workspace:*",
1414
"dotenv": "^16.4.7",
15-
"undici": "^7.10.0"
15+
"undici": "^7.11.0"
1616
},
1717
"devDependencies": {
1818
"ts-node": "^10.9.2",

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"async-lock": "^1.4.0",
5454
"bson": "^6.6.0",
5555
"comlink": "^4.4.2",
56-
"undici": "^7.10.0"
56+
"undici": "^7.11.0"
5757
},
5858
"devDependencies": {
5959
"@powersync/drizzle-driver": "workspace:*",

packages/node/src/sync/stream/ErrorRecordingDispatcher.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

packages/node/src/sync/stream/NodeRemote.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
ProxyAgent,
2020
WebSocket as UndiciWebSocket
2121
} from 'undici';
22-
import { ErrorRecordingDispatcher } from './ErrorRecordingDispatcher.js';
2322

2423
export const STREAMING_POST_TIMEOUT_MS = 30_000;
2524

@@ -65,26 +64,15 @@ export class NodeRemote extends AbstractRemote {
6564
protected createSocket(url: string): globalThis.WebSocket {
6665
// Create dedicated dispatcher for this WebSocket
6766
const baseDispatcher = this.getWebsocketDispatcher(url);
68-
const errorRecordingDispatcher = new ErrorRecordingDispatcher(baseDispatcher);
6967

7068
// Create WebSocket with dedicated dispatcher
7169
const ws = new UndiciWebSocket(url, {
72-
dispatcher: errorRecordingDispatcher,
70+
dispatcher: baseDispatcher,
7371
headers: {
7472
'User-Agent': this.getUserAgent()
7573
}
7674
});
7775

78-
errorRecordingDispatcher.onError = (error: Error) => {
79-
// When we receive an error from the Dispatcher, emit the event on the websocket.
80-
// This will take precedence over the WebSocket's own error event, giving more details on what went wrong.
81-
const event = new ErrorEvent('error', {
82-
error,
83-
message: error.message
84-
});
85-
ws.dispatchEvent(event);
86-
};
87-
8876
return ws as globalThis.WebSocket;
8977
}
9078

0 commit comments

Comments
 (0)