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

fix: unhandled on network drop when provider is not initialized #5446

Merged
merged 4 commits into from
Oct 17, 2024

Conversation

ganchoradkov
Copy link
Member

Description

fixed an unhandled exception inprovider.disconnect() when provider is not initialized and subscribeToNetworkChange triggered disconnect flow

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Draft PR (breaking/non-breaking change which needs more work for having a proper functionality [Mark this PR as ready to review only when completely ready])
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How has this been tested?

tests, dogfooding

Checklist

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Additional Information (Optional)

Please include any additional information that may be useful for the reviewer.

@ganchoradkov ganchoradkov requested review from Cali93 and bkrem October 16, 2024 13:22
@arein arein added the accepted label Oct 16, 2024
@@ -287,7 +287,7 @@ export class Relayer extends IRelayer {
}
}

if (this.hasExperiencedNetworkDisruption || this.connected) {
if (this.provider.disconnect && (this.hasExperiencedNetworkDisruption || this.connected)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be safer to use the optional chain operator or it's not needed ?

Suggested change
if (this.provider.disconnect && (this.hasExperiencedNetworkDisruption || this.connected)) {
if (this.provider?.disconnect && (this.hasExperiencedNetworkDisruption || this.connected)) {

Copy link
Member Author

Choose a reason for hiding this comment

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

no need as this.provider is {} if not yet initialized. Being {} is covered by other tests

Copy link
Member

@bkrem bkrem left a comment

Choose a reason for hiding this comment

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

🙏

cc @alexsserban @tomiir this should fix the this.provider.disconnect is not a function issue that bubbles up on AppKit implementations

@ganchoradkov ganchoradkov merged commit 6f59b92 into v2.0 Oct 17, 2024
9 checks passed
@ganchoradkov ganchoradkov deleted the fix/unhandled-on-network-drop branch October 17, 2024 10:21
@ganchoradkov ganchoradkov mentioned this pull request Nov 5, 2024
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants