fix(web): remove unload event listener to fix Chrome 146+ deprecation#924
fix(web): remove unload event listener to fix Chrome 146+ deprecation#924JexanJoel wants to merge 2 commits intopowersync-ja:mainfrom
Conversation
|
|
Based on the discussion in #912, I've removed the unload listeners entirely since navigator locks now handle tab detection. Happy to revert or adjust if more testing is needed before this is merged. |
6af1e0a to
1ced517
Compare
There was a problem hiding this comment.
I ran a quick manual test of these changes in the react supabase todolist demo app. Closing a tab providing the database for the sync worker still makes it retry with a different tab, so it looks like the unload listeners indeed aren't necessary anymore.
I'd like to wait for Steven to also take a look once he's back, in case he finds additional issues to look out for.
| export type WebPowerSyncDatabaseOptionsWithAdapter = WithWebSyncOptions | ||
| WithWebFlags<PowerSyncDatabaseOptionsWithDBAdapter> | ||
| >; | ||
| export type WebPowerSyncDatabaseOptionsWithOpenFactory = WithWebSyncOptions< | ||
| export type WebPowerSyncDatabaseOptionsWithOpenFactory = WithWebSyncOptions | ||
| WithWebFlags<PowerSyncDatabaseOptionsWithOpenFactory> | ||
| >; | ||
| export type WebPowerSyncDatabaseOptionsWithSettings = WithWebSyncOptions< | ||
| export type WebPowerSyncDatabaseOptionsWithSettings = WithWebSyncOptions | ||
| WithWebFlags<WithWebEncryptionOptions<PowerSyncDatabaseOptionsWithSettings>> |
There was a problem hiding this comment.
Why did these change, isn't this just a syntax error now?
There was a problem hiding this comment.
Sorry about that, it got mangled during editing. fixed now!
| } | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Please run this file through prettier.
There was a problem hiding this comment.
Done, ran it through, should be clean now. And thanks for testing it manually, appreciate it! Happy to wait for Steven's review.
a4d3558 to
8f6dcf5
Compare
Fixes #912
Based on maintainer feedback in #912, the
unloadevent listeners have been removed entirely rather than replaced withpagehide.pagehideis not appropriate here becauseclose()is a terminal action - if the tab is restored from bfcache, the database would remain closed.Since navigator locks now reliably handle tab detection, the
unloadlisteners are no longer needed.Changes in
packages/web/src/db/PowerSyncDatabase.ts:unloadListenerpropertywindow.addEventListener('unload', ...)block from constructorwindow.removeEventListener('unload', ...)block fromclose()