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

'unload' event is deprecated #1508

Open
bhousel opened this issue Aug 6, 2024 · 3 comments
Open

'unload' event is deprecated #1508

bhousel opened this issue Aug 6, 2024 · 3 comments
Labels
chore Improvements to the code or development stack, cleanups

Comments

@bhousel
Copy link
Contributor

bhousel commented Aug 6, 2024

We use this event to release the localStorage mutex, but it seems like browsers are dropping support for it.

window.addEventListener('unload', () => this._mutex.unlock());

more info here
https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event
https://chromestatus.com/feature/5579556305502208

@bhousel bhousel added the chore Improvements to the code or development stack, cleanups label Aug 6, 2024
@eneerhut
Copy link

eneerhut commented Oct 3, 2024

Is the purpose of this event to help us understand when someone leaves the site @bhousel?

@bhousel
Copy link
Contributor Author

bhousel commented Oct 3, 2024

Is the purpose of this event to help us understand when someone leaves the site @bhousel?

Yes - the "mutex" mentioned above is a trick that means that if you have multiple Rapid tabs open then only one of them will be allowed to backup the user's edits. When you close the tab, it releases that lock.

The whole thing is kind of messy and we should probably rethink how saving user's backups should work.

@eneerhut
Copy link

eneerhut commented Oct 3, 2024

Thanks for clarifying. Sounds like pretty core functionality to avoid failure states and edit conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Improvements to the code or development stack, cleanups
Projects
None yet
Development

No branches or pull requests

2 participants