Skip to content

Commit 033fc4f

Browse files
authored
Adjust x-ws usage (#5511)
1 parent 4ca9670 commit 033fc4f

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Changes:
1111

1212
- Ensure that provider disconnect clears all subscriptions
1313
- Adjust typegen to internally use `import()` (catering for ESM provided types)
14+
- Swap TS -> JS compiler to use tsc (from babel)
15+
- Adjust all tests to use `node:test` runner (ESM variants)
1416
- Update to latest Polkadot, Kusama & Substrate metadata
1517

1618

packages/rpc-provider/src/ws/index.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ const RETRY_DELAY = 2_500;
4545
const DEFAULT_TIMEOUT_MS = 60 * 1000;
4646
const TIMEOUT_INTERVAL = 5_000;
4747

48-
const MEGABYTE = 1024 * 1024;
49-
5048
const l = logger('api-ws');
5149

5250
function eraseRecord<T> (record: Record<string, T>, cb?: (item: T) => void): void {
@@ -213,16 +211,9 @@ export class WsProvider implements ProviderInterface {
213211
this.#websocket = typeof xglobal.WebSocket !== 'undefined' && isChildClass(xglobal.WebSocket as typeof WebSocket, WebSocket)
214212
? new WebSocket(this.endpoint)
215213
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
216-
// @ts-ignore - WS may be an instance of w3cwebsocket, which supports headers
217-
: new WebSocket(this.endpoint, undefined, undefined, this.#headers, undefined, {
218-
// default: true
219-
fragmentOutgoingMessages: true,
220-
// default: 16K (bump, the Node has issues with too many fragments, e.g. on setCode)
221-
fragmentationThreshold: 1 * MEGABYTE,
222-
// default: 1MiB (also align with maxReceivedMessageSize)
223-
maxReceivedFrameSize: 24 * MEGABYTE,
224-
// default: 8MB (however Polkadot api.query.staking.erasStakers.entries(356) is over that, 16M is ok there)
225-
maxReceivedMessageSize: 24 * MEGABYTE
214+
// @ts-ignore - WS may be an instance of ws, which supports options
215+
: new WebSocket(this.endpoint, undefined, {
216+
headers: this.#headers
226217
});
227218

228219
if (this.#websocket) {

0 commit comments

Comments
 (0)