Adjust x-ws usage (#5511)

This commit is contained in:
Jaco
2023-03-04 17:13:41 +02:00
committed by GitHub
parent 4ca9670e4e
commit 033fc4f480
2 changed files with 5 additions and 12 deletions
+2
View File
@@ -11,6 +11,8 @@ Changes:
- Ensure that provider disconnect clears all subscriptions
- Adjust typegen to internally use `import()` (catering for ESM provided types)
- Swap TS -> JS compiler to use tsc (from babel)
- Adjust all tests to use `node:test` runner (ESM variants)
- Update to latest Polkadot, Kusama & Substrate metadata
+3 -12
View File
@@ -45,8 +45,6 @@ const RETRY_DELAY = 2_500;
const DEFAULT_TIMEOUT_MS = 60 * 1000;
const TIMEOUT_INTERVAL = 5_000;
const MEGABYTE = 1024 * 1024;
const l = logger('api-ws');
function eraseRecord<T> (record: Record<string, T>, cb?: (item: T) => void): void {
@@ -213,16 +211,9 @@ export class WsProvider implements ProviderInterface {
this.#websocket = typeof xglobal.WebSocket !== 'undefined' && isChildClass(xglobal.WebSocket as typeof WebSocket, WebSocket)
? new WebSocket(this.endpoint)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - WS may be an instance of w3cwebsocket, which supports headers
: new WebSocket(this.endpoint, undefined, undefined, this.#headers, undefined, {
// default: true
fragmentOutgoingMessages: true,
// default: 16K (bump, the Node has issues with too many fragments, e.g. on setCode)
fragmentationThreshold: 1 * MEGABYTE,
// default: 1MiB (also align with maxReceivedMessageSize)
maxReceivedFrameSize: 24 * MEGABYTE,
// default: 8MB (however Polkadot api.query.staking.erasStakers.entries(356) is over that, 16M is ok there)
maxReceivedMessageSize: 24 * MEGABYTE
// @ts-ignore - WS may be an instance of ws, which supports options
: new WebSocket(this.endpoint, undefined, {
headers: this.#headers
});
if (this.#websocket) {