ccorcos / tuple-database

410 stars 20 forks source link

Subscribe query destroy bug #12

Closed tanishqkancharla closed 2 years ago

tanishqkancharla commented 2 years ago

The following situation arises in tuple db:

subscribe query A subscribe query B

some transaction is committed.

callback A is enqueued callback B is enqueued

query A recomputes, and executes the callback. In this callback, it destroys query B. However, query B is still enqueued, so it recomputes and executes its callback anyway (which is probably invalid after query A destroyed it).

This PR fixes that situation.

ccorcos commented 2 years ago

I need to see a concrete reproduction of the issue. Because the line if (txId === lastComputedTxId) return should take care of any issues like this so it doesn't emit more than once.