Comments (3)
Man, I'm jealous of your coworkers if this is the kind of bug reports and pull requests they routinely get from you! Really great stuff here.
I think you're right about the cause of the problem, and that the change you made in your PR is the solution least likely to cause other problems, since it's the most similar to how it works now.
I included this fix in v3.1.2.
from fakeindexeddb.
Thanks for the detailed bug report. I spent a little time playing around with it. Looks like each bulkGet
is its own transaction, and each promise resolves when the transaction finishes. But in your test case, somehow the 3rd transaction never resolves.
The only difference I see in Dexie's code is that when no keys are given, it resolves the promise faster, because it doesn't have to wait for the async response from actually getting data. But I don't immediately know why that would be a problem. It still looks like the 1st is resolving, then the 2nd is resolving, and then the 3rd... never. Why would the 2nd resolving faster impact the 3rd? Strange. Gets into some hairy parts of fake-indexeddb, probably. I'll have to come back to this later.
from fakeindexeddb.
Thanks for the quick response. (And big thanks for fakeIndexedDB!)
Spent a little time in the debugger, and I think I see the problem:
- Database.processTransactions finds the next unfinished transaction, starts it, and then adds itself as a "complete" listener to continue the process with any remaining transactions
- If there are no remaining requests in the transaction, FDBTransaction._start immediately marks the transaction finished and dispatches the "complete" event
- Dexie's
bulkGet([])
generates an FDBTransaction with no requests. This means the "complete" is dispatched before processTransactions has added its listener, so processTransactions is never run again to get to the remaining transactions.
I think that means the issue is better stated as: if there are ever transactions with no requests, any subsequent transactions may not be processed.
Not sure what the right fix would be. Maybe one of:
- In FDBTransation._start, delay the dispatch(complete) until the next cycle?
- In Database.processTransactions, attach the event listeners before executing next._start?
- In Database.processTransactions, check if executing next._start has left next finished, and if so immediately re-schedule processTransactions?
from fakeindexeddb.
Related Issues (20)
- setTimeout problems / questions HOT 4
- 3.1.6 regression: `ReferenceError: setImmediate is not defined` HOT 1
- orderBy support HOT 4
- initialize the DB before the use. HOT 2
- Add observation for Dexie users HOT 3
- [BUG] Context loosing for `FakeDOMStringList` members while wrapping IDB
- [BUG] Invalid behavior for concurrent insertion data HOT 1
- Ref of Observable from liveQuery is not reactive HOT 7
- fake-indexeddb fails when happy-dom is loaded prior to fake-indexeddb HOT 3
- Running this in Chrome throws "Cannot set property indexedDB of #<Window> which has only a getter" HOT 3
- Release new version to npm with latest types fix HOT 3
- DataCloneError: The data being stored could not be cloned by the internal structured cloning algorithm. HOT 2
- Problem storing and retrieving CryptoKeys HOT 2
- structuredClone and jsdom HOT 7
- `Uint8Array` keys don't respect offsets from underlying ArrayBuffers HOT 3
- Serializing (and restoring) the state of Fake IDB HOT 1
- Unable to use in tests that mock timers (e.g. overriding `globalThis.setImmediate`) HOT 6
- `IDBObjectStore.count` is `O(n^2)` HOT 3
- Try using built-in Node.js Blob HOT 1
- How to read one of the chrome database HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fakeindexeddb.