3box-js icon indicating copy to clipboard operation
3box-js copied to clipboard

onSyncDone race conditions

Open Schwartz10 opened this issue 6 years ago • 3 comments

Describe the bug If onSyncDone is called too late after Box.openBox, the call hangs and the registered callback listener never fires

To Reproduce

const openedBox = await Box.openBox(ethereumAddress, web3)

setTimeout(() => {
  openedBox.onSyncDone(() => {
    // unreachable code, callback never fires
  })
}, 5000)

Expected behavior The callback should fire if the box has already synced

Schwartz10 avatar Jul 23 '19 18:07 Schwartz10

An update from @chadoh (another dev who was experiencing hanging calls) - he's on Brave browser and saw these warnings in the console:

Warning: Given input entry is not allowed in this log and was discarded (no write access).

Store.js:258 "WARNING! Head hash didn't match the contents

Warning: Given input entry is not allowed in this log and was discarded (no write access).

[Violation] 'setInterval' handler took 76ms

He can't consistently unlock a box on brave, using code directly from the 3box docs. Either calls hang, or the box unlocks extremely quickly.

Schwartz10 avatar Jul 23 '19 19:07 Schwartz10

Just jotting some notes down here, it is possible that the syncing flow gets stuck on this line. I'm happy to debug further but going to hang tight for now and wait to see if y'all have any ideas

Schwartz10 avatar Jul 23 '19 21:07 Schwartz10

Seems like what @chadoh is experiencing might be a bit of a different issue. Or what do you mean by "unlock a box" exactly? Sounds like it has something to do with openBox not working. Are you referring to onSyncDone specifically though?

oed avatar Jul 24 '19 08:07 oed