Page MenuHomePhabricator

[web] Release lock on app hot reload
ClosedPublic

Authored by michal on Feb 19 2024, 10:06 AM.
Tags
None
Referenced Files
F3359427: D11114.id37778.diff
Sun, Nov 24, 9:01 AM
F3359071: D11114.diff
Sun, Nov 24, 6:56 AM
Unknown Object (File)
Sat, Nov 16, 5:46 PM
Unknown Object (File)
Sat, Nov 16, 5:46 PM
Unknown Object (File)
Sat, Nov 16, 5:46 PM
Unknown Object (File)
Sat, Nov 16, 5:45 PM
Unknown Object (File)
Sat, Nov 16, 5:45 PM
Unknown Object (File)
Sun, Nov 10, 1:13 AM
Subscribers

Details

Summary

ENG-6669 : Release the lock on webpack auto-reload
There is a small issue with the lock API -> during webpack hot reload we lose the reference to the lock, which means that the tab which is holding the lock is thinking that somebody else has it. The easiest way to solve this is to use the functions provided by webpack to run function during hot reload, in this case the function to release the lock.

Depends on D11113

Test Plan

Add this code:

const { lockStatus, releaseLock } = useWebLock('lock');
React.useEffect(() => {
   document.title = lockStatus;

   if(lockStatus === 'should-release') {
     // Add some delay to simulate closing the tunnelbroker socket
     setTimeout(releaseLock, 1000);
   }
 }, [lockStatus]);

Try switching between different tabs quickly, and changing some code in the webapp so it gets hot-reloaded. Check that at all times the only tab holding the lock is one of the tabs in the foreground (except for the 1s delay before call to releaseLock).

Try running it in production code to make sure it's not broken.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

web/web-lock.js
135–138 ↗(On Diff #37338)

Should this type be read-only?

kamil added inline comments.
web/web-lock.js
93 ↗(On Diff #37338)

We should be able to return undefined?

This revision is now accepted and ready to land.Mar 4 2024, 5:56 AM