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

feat(push): add callback on subscription lost event #2737

Conversation

cromoteca
Copy link
Contributor

@cromoteca cromoteca commented Sep 17, 2024

This PR allows to define a behavior for when the reopened event happens on the client.

The new onSubscriptionLost callback can be used to perform an action when the websocket is reopened, but there's no longer a Flux connected to the subscription. Based on the return value of that callback, automatic resubscription can be performed.

Fixes #2716

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.

Project coverage is 94.48%. Comparing base (ec4ba7f) to head (c18d859).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/ts/frontend/src/FluxConnection.ts 83.33% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2737      +/-   ##
==========================================
- Coverage   94.53%   94.48%   -0.05%     
==========================================
  Files          81       81              
  Lines        2635     2648      +13     
  Branches      664      666       +2     
==========================================
+ Hits         2491     2502      +11     
- Misses        140      142       +2     
  Partials        4        4              
Flag Coverage Δ
unittests 94.48% <83.33%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cromoteca cromoteca changed the title fix(push): resubscribe after reconnecting fix!(push): resubscribe after reconnecting Sep 17, 2024
@cromoteca cromoteca changed the title fix!(push): resubscribe after reconnecting fix(push): resubscribe after reconnecting Sep 18, 2024
@cromoteca cromoteca marked this pull request as ready for review September 19, 2024 07:59
@cromoteca cromoteca changed the title fix(push): resubscribe after reconnecting feat(push): add callback on subscription lost event Sep 19, 2024
Copy link

sonarcloud bot commented Sep 20, 2024

Copy link
Contributor

@taefi taefi left a comment

Choose a reason for hiding this comment

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

LGTM and can be merged when the tests are passed.

Comment on lines +234 to +238
throw new Error(
endpointInfo
? `Error in ${endpointInfo.endpointName}.${endpointInfo.methodName}(${JSON.stringify(endpointInfo.params)}): ${message.message}`
: `Error in unknown subscription: ${message.message}`,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: A test can be added to cover this change.

@platosha platosha merged commit 7f11dfc into main Sep 23, 2024
13 of 15 checks passed
@platosha platosha deleted the fix/2716/push-client-tries-to-reconnect-to-a-Flux-that-no-longer-exists branch September 23, 2024 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[push] client tries to reconnect to a Flux that no longer exists
3 participants