onSyncDone race conditions
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
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.
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
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?