powersync-ja / powersync-js

SDK that enables local-first and real-time reactive apps with embedded SQLite for JavaScript clients, including React Native and Web
https://www.powersync.com
Apache License 2.0
300 stars 21 forks source link

[Fix] Stale credentials in mulitple tabs #257

Closed stevensJourney closed 2 months ago

stevensJourney commented 2 months ago

Overview

This fixes a bug when using multiple tab functionality where: the Shared sync manager would "hold on" to credentials previously provided to it. This was due to the shared worker previously mainlining a single instance of AbstractStreamingSyncImplementation. This implementation would use cached credentials until they expired. This is particularly bad if the tab remains open after disconnectAndClear has been called and the user has "signed out".

Most of our SDKs currently create a new instance of the StreamingSync implementation on each connect call. This effectively will clear any caches.

The shared sync manager now creates the streaming sync implementation when the connect call is invoked. This ensures the fetchCredentials of the BackendConnector is called for each call to connect.

changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: cda9e954e301a122d8bfa413adac14d449ee46d8

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

This PR includes changesets to release 2 packages | Name | Type | | -------------------------- | ----- | | @powersync/web | Patch | | @powersync/diagnostics-app | 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