bitovi / bitovi/web-locks-polyfill

Locks overwriting each other and acquired by more than one tab at same time

Open
#5 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3
Forks
1
PR merge metrics
No merged PRs in 30d

Description

### Problem

Locks are being acquired by more than one tab at the same time when they should not be.

### Reproduction
In my testing of this polyfill package, I am opening three tabs very close together. Occasionally, the lock appears to be acquired by more than one tab at the same time. Here is my log output from the three separate tabs.

Tab 1
```
[Log] 1616447907354 – "clientId" – "8679140820985151" (0.chunk.js, line 188498)
[Log] useAnonymousSignup - requesting lock - now: – 1616447908142 (main.chunk.js, line 28892)
[Log] 1616447908143 – "8679140820985151:1" – "set innerKey. InnerKey was" – null (0.chunk.js, line 188498)
[Log] 1616447908254 – "8679140820985151:1" – "locked" (0.chunk.js, line 188498)
[Log] useAnonymousSignup - lock acquired - now: – 1616447908255 – " cancelled:" – false – " accessToken:" – undefined (main.chunk.js, line 28894)
[Log] useAnonymousSignup - lock releasing - now: – 1616447909542 (main.chunk.js, line 28904)
[Log] 1616447909551 – "8679140820985151:1" – "unlocked" (0.chunk.js, line 188498)
```

Tab 2
```
[Log] 1616447907700 – "clientId" – "4030941946461747" (0.chunk.js, line 188498)
[Log] useAnonymousSignup - requesting lock - now: – 1616447908380 (main.chunk.js, line 28892)
[Log] 1616447908381 – "4030941946461747:1" – "set innerKey. InnerKey was" – null (0.chunk.js, line 188498)
[Log] 1616447908499 – "4030941946461747:1" – "outerKeyAlreadyOwned. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447908549 – "4030941946461747:1" – "innerKeyAlreadyOwned. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447908570 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447908610 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447909479 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910063 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910146 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910188 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910230 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910353 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910374 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910394 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910570 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910674 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447910828 – "4030941946461747:1" – "innerKeyAlreadyOwned backing off. Owned by" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447911479 – "4030941946461747:1" – "set innerKey. InnerKey was" – null (0.chunk.js, line 188498)
[Log] 1616447912498 – "4030941946461747:1" – "locked" (0.chunk.js, line 188498)
[Log] useAnonymousSignup - lock acquired - now: – 1616447912502 (main.chunk.js, line 28894)
[Log] useAnonymousSignup - lock releasing (main.chunk.js, line 28897)
[Log] 1616447912502 – "4030941946461747:1" – "unlocked" (0.chunk.js, line 188498)
```

Tab 3
```
[Log] 1616447907697 – "clientId" – "08631345487356656" (0.chunk.js, line 188498)
useAnonymousSignup - requesting lock - now: – 1616447908390
[Log] 1616447908390 – "08631345487356656:1" – "set innerKey. InnerKey was" – null (0.chunk.js, line 188498)
[Log] 1616447908555 – "08631345487356656:1" – "outerKeyAlreadyOwned. Owned by" – "4030941946461747:1" (0.chunk.js, line 188498)
[Log] 1616447908588 – "08631345487356656:1" – "set innerKey. InnerKey was" – "08631345487356656:1" (0.chunk.js, line 188498)
[Log] 1616447908623 – "08631345487356656:1" – "locked" (0.chunk.js, line 188498)
[Log] useAnonymousSignup - lock acquired - now: – 1616447908623" (main.chunk.js, line 28894)
[Log] useAnonymousSignup - lock releasing - now: – 1616447911212 (main.chunk.js, line 28904)
[Log] 1616447911219 – "08631345487356656:1" – "unlocked" (0.chunk.js, line 188498)
```

Expected Behavior
Lock should only be able to be acquired by one tab at a time.

Environment
- mac OSX 10.15.7
- Safari 14.0.2

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue by requesting the lock from three Safari tabs close together, then compare the acquisition and release timestamps in the logged lock paths. Trace the implementation that emits “outerKeyAlreadyOwned”, “innerKeyAlreadyOwned”, and “locked”; done means no more than one tab reports the lock as acquired at a time.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.