firebase-js-sdk
firebase-js-sdk copied to clipboard
unresolved get cause onValue to not be called on child path
Describe your environment
- Operating System version: linux
- Browser version: chrome latest
- Firebase SDK version: JS SDK v9.8.4
- Firebase Product:
Describe the problem
onValue
callback function on node for which a get on a parent has not yet resoved will never be called. This is pretty bad as get
seems to have unpredictable side-effect.
get should not have ANY side-effect.
Possibly related to https://github.com/firebase/firebase-js-sdk/issues/6038. Took me ages to identify the reason for some part of my app failing while transitionning to v9.
Work around for now: avoid any use of get, replace by a thenable onValue ... {onlyOnce: true}
Steps to reproduce:
go there - possibly adjust the ms
property
The test case is fragile as it depends on race conditions. So please adjust the ms
wait property to see the test fail.
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Any news on this?
Can you reproduce the faulty behavior ?
This still happens under 9.9.1
@christophe-g I was able to reproduce the issue. I am looking into it.
@christophe-g we were able to reproduce this with once as well. Can you provide an example where the correct behavior is observed with once?
Thanks for looking into this @maneesht . Not sure if you still need examples, but I have consistently repeatable demos in stackblitz showing the change in behaviour between 9.8.3, 9.8.4, and 9.8.4 with the workaround mentioned:
The defect is triggered when there's a get
and an onValue
after the connection has already been established, so there's a dummy query just to get firebase connected before rendering the test component. 9.8.3 the once
and live
values both populate but in 9.8.4 only once
is populated.
@nauzilus - thanks for the thorough examples. We were able to create a test case to prevent this from happening again. The fix should be in soon.