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] WebSocket Close #44

Merged
merged 1 commit into from
Jul 18, 2024
Merged

[Fix] WebSocket Close #44

merged 1 commit into from
Jul 18, 2024

Conversation

stevensJourney
Copy link
Collaborator

Overview

When closing a WebSocket connection, e.g. by closing a web tab, the router did not immediately detect that the connection has been closed.

The connection would close when the keep-alive ping-pong check failed, but the delay could cause the number of concurrent connections and active streams to accumulate for short periods.

This bubbles the WebSocket close event through the WebSocket Duplex connection and router endpoint handlers.

Thanks @rkistner for finding the issue and providing a fix.

Testing

This was tested locally with web and React Native. See screenshots below where the STREAM log duration is below the keep-alive period of 30_000ms.

Screenshot 2024-07-18 at 14 09 30 Screenshot 2024-07-18 at 14 14 27

The close unit test was updated to ensure that the cancel event is called correctly. Oddly enough this extended test actually would pass with the previous code - the bug is only reproducible with an actual connection.

Copy link

changeset-bot bot commented Jul 18, 2024

🦋 Changeset detected

Latest commit: ed9a80b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@powersync/service-rsocket-router Patch
@powersync/service-core Patch
@powersync/service-image Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@stevensJourney stevensJourney marked this pull request as ready for review July 18, 2024 12:24
@stevensJourney stevensJourney merged commit 9bff878 into main Jul 18, 2024
7 checks passed
@stevensJourney stevensJourney deleted the fix/websockets-close branch July 18, 2024 12:57
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.

2 participants