-
Notifications
You must be signed in to change notification settings - Fork 682
fix: implement backoff retry policy for websocket handler #3600
base: develop
Are you sure you want to change the base?
fix: implement backoff retry policy for websocket handler #3600
Conversation
src/chains/ethereum/ethereum/src/forking/handlers/ws-handler.ts
Outdated
Show resolved
Hide resolved
src/chains/ethereum/ethereum/src/forking/handlers/ws-handler.ts
Outdated
Show resolved
Hide resolved
src/chains/ethereum/ethereum/src/forking/handlers/ws-handler.ts
Outdated
Show resolved
Hide resolved
}); | ||
this.connection.binaryType = "nodebuffer"; | ||
this.connection.onclose = onCloseEvent; | ||
this.open = this.connect(this.connection, logging); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a inFlightRequests
that may need care/attention here. I am not sure if the desired behavior would be to kill/cancel them or attempt to rebroadcast if/once the socket reconnects and if that's possible. I don't know this part of code. I would assume the latter but @davidmurdoch will need to clarify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @davidmurdoch : Will this change have any impact on inFlightRequests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tenthirtyone , @davidmurdoch : In flight requests are now stored when connection is closed and processed once connection retry attempt succeeds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a review, I just had a question.
src/chains/ethereum/ethereum/src/forking/handlers/ws-handler.ts
Outdated
Show resolved
Hide resolved
Would it be possible to get tests added for this change? |
|
26586c8
to
7cdc04e
Compare
Web socket handler receives closed connection event more frequently than expected from infura server. So to make ganache more robust a backoff retry mechanism is implemented.
Retry configuration - 3 retries with 2 seconds initial retry and with exponential attempts followed.
When connection is closed, in flight requests are stored temporarily and processed once connection retry attempt succeeds.
Note: Once connection is successful, the retry counter is reset to initial counter.