Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocketProvider error. WS_ERR_UNSUPPORTED_MESSAGE_LENGTH #4803

Open
whytereshchenko opened this issue Aug 8, 2024 · 0 comments
Open

WebSocketProvider error. WS_ERR_UNSUPPORTED_MESSAGE_LENGTH #4803

whytereshchenko opened this issue Aug 8, 2024 · 0 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@whytereshchenko
Copy link

Ethers Version

6.13.2

Search Terms

ws, websockets, message_length

Describe the Problem

We have an uncaught exception from the ethers library when calling the method provider.getBlock() or provider.getLogs(). We can't determine where this error occurs or what causes it. I suspect that the ethers library is not catching this error.

Could this be caused by a large number of blocks, as my function processMissedBlocks() processes a thousand blocks for each of the six networks?

How to handle this?

We just moved to v6 from v5.

Provider initialization:

 Provider: new ethers.WebSocketProvider(`url`, ethers.Network.from(56), {
                polling: true,
                staticNetwork: true,
            }),

Code Snippet

private async processingLogs(token: DepositToken, filter: {address: string, fromBlock: number, toBlock: number, topics: string[]}, txHash?: string) {
        const provider = this.provider[token.network];
        let events = await provider.getLogs(filter).catch((e) => {
            transactionsLogger.error(e)
        });

        if(!events) return;

        const indexTxHash = txHash ? events.findIndex(log => log.transactionHash === txHash) : -1;
        if (indexTxHash !== -1) {
            events = events.slice(indexTxHash+1);
        }

        for (const event of events) {
            this.processContractEvent(token, event);
        }
    }


 private async processBlock(provider: Provider, token: DepositToken, blockNumber: number) {
        const block = await provider.getBlock(blockNumber, true).catch((e) => {
            transactionsLogger.error(e)
        });

      // process logic
}

Contract ABI

No response

Errors

Error: {"code":1,"reason":{"code":"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"},"signal":"uncaughtException"}

Environment

node.js (v12 or newer)

Environment (Other)

QuickNode

@whytereshchenko whytereshchenko added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants