firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

unresolved get cause onValue to not be called on child path

Open christophe-g opened this issue 2 years ago • 7 comments

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.

christophe-g avatar Jun 28 '22 08:06 christophe-g

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Jun 28 '22 08:06 google-oss-bot

Any news on this?

Can you reproduce the faulty behavior ?

christophe-g avatar Jul 08 '22 09:07 christophe-g

This still happens under 9.9.1

christophe-g avatar Jul 25 '22 15:07 christophe-g

@christophe-g I was able to reproduce the issue. I am looking into it.

maneesht avatar Jul 28 '22 21:07 maneesht

@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?

maneesht avatar Aug 01 '22 19:08 maneesht

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 avatar Aug 09 '22 00:08 nauzilus

@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.

maneesht avatar Aug 09 '22 02:08 maneesht