firebase / firebase/geofire-js

'ready' callback fires prematurely when updateCriteria() is called again before its previous invocation has been completed

Open
#194 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
1.4k
Forks
339
PR merge metrics
No merged PRs in 30d

Description

Prerequisites:
Test with no network connectivity

Steps:
1.) Start a location update for a specific location
2.) Follow up with an update criteria call. (This has to happen before step 1, hence the no network connectivity scenario being simulated)

Note that in my case, there are ~30 geofire keys to be returned when there is network connectivity.

Actual:
A 'ready' event is falsely fired for the second call, even though the db was not queried yet. The code is ignoring the current queries ongoing for the second call, and thinks that there are no outstanding queries when the second call is invoked because of this line that I replaced:
this._outstandingGeohashReadyEvents = geohashesToQuery.slice();

Expected: (After this change)
The 'ready' event is only fired when all existing queries have been returned.

See my fix:
https://github.com/crocodile/geofire-js/blob/829bc49c04800b09df198cb81be03e11405caaef/src/GeoQuery.ts#L406-L411

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/GeoQuery.ts around lines 406-411 and trace how repeated updateCriteria() calls track outstanding geohash queries. Reproduce the no-network sequence from the issue, then verify that the second ready event is emitted only after all existing queries have returned.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.