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 · 1 comment
Open

WebSocketProvider error. WS_ERR_UNSUPPORTED_MESSAGE_LENGTH #4803

whytereshchenko opened this issue Aug 8, 2024 · 1 comment
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
@ricmoo
Copy link
Member

ricmoo commented Oct 16, 2024

Both v5 and v6 use the same ws library in Node for handling WebSockets.

There is a recent security fix to the ws package though, but I don't think that is related.

Can you try adding provider.on("debug", console.log) and trigger the error to see what bytes are going/coming over the wire when it happens?

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