Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

fix: mark the socket as closed when receiving a close/error message #25180

Merged
merged 1 commit into from
May 13, 2022
Merged

fix: mark the socket as closed when receiving a close/error message #25180

merged 1 commit into from
May 13, 2022

Conversation

steveluscher
Copy link
Contributor

@steveluscher steveluscher commented May 13, 2022

Problem

In solana-labs/solana-web3.js#1177 @awojciak noticed that the subscriptions manager would keep trying to slam a closed socket with requests. I believe this is because we were not properly marking the socket as closed when receiving a 'close' event.

Summary of Changes

Toggle the connectedness flag when we get a close/error event.

Fixes solana-labs/solana-web3.js#1177.

@@ -4174,13 +4174,15 @@ export class Connection {
* @internal
*/
_wsOnError(err: Error) {
this._rpcWebSocketConnected = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MDN says:

The error event is fired when a connection with a WebSocket has been closed due to an error (some data couldn't be sent for example).

@steveluscher steveluscher requested review from jstarry and jordaaash May 13, 2022 01:23
@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #25180 (6d7f73e) into master (8468f80) will increase coverage by 0.1%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##           master   solana-labs/solana#25180     +/-   ##
=========================================
+ Coverage    75.1%    75.2%   +0.1%     
=========================================
  Files          38       38             
  Lines        2243     2245      +2     
  Branches      323      323             
=========================================
+ Hits         1686     1690      +4     
+ Misses        444      443      -1     
+ Partials      113      112      -1     

@jstarry
Copy link
Contributor

jstarry commented May 13, 2022

I think you're right about this being the root problem, nice!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

web3.js: _updateSubscriptions running in infinite recursion, crashing developed app
2 participants