-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
idb correctness currently relies on invalid assumptions about the executor #18
Comments
Thanks for creating this issue. I haven't delved deeper into |
Right, that's because all of The exact commit I'm using to reproduce is this one. You can ignore the wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); My process to reproduce is 1. run cargo test -p idb --test transaction test_transaction_commit If you remove the |
That is incorrect, |
Hmm that's weird, I was unable to reproduce without adding the Happy that you managed to reproduce anyway! |
We only need to add |
Any updates on this? Was this problem resolved? |
Unfortunately there’s no easy way to solve this as IndexedDB has weird auto-commit behaviour. In general, it is a good practice to not have long-lived transactions in IndexedDB. One thing which you can do is to not call This issue is only for multi-threaded executors in nightly rust when |
Currently,
idb
relies on behavior of the futures executor that is not actually specified: it assumes that waking a task from an IndexedDB callback, and then returning from the IndexedDB callback, will result in the awoken task being executed before returning to the browser event loop.This is not necessarily true, and in particular breaks with the multi-threaded wasm-bindgen executor. I opened an issue upstream, but unfortunately it seems hard to fix, and was closed as wontfix, because that specific behavior of the singlethread executor was never documented in the first place:
I'm opening this issue to let you know about this current limitation of idb. Please don't just comment on the upstream issue without carefully considering whether you're bringing something new to the table, as that would only be bad vibes for the wasm-bindgen maintainers, and they're doing an awesome job.
On my end I'm planning to fix this in my IndexedDB crate via this change that makes the transaction only ever execute from the callbacks. I verified and it works with the multi-threaded executor, but it also requires a slightly less convenient API. I'm hoping one of the places where I'm opening this issue will have an idea for how to handle this differently :)
Hope that helps!
The text was updated successfully, but these errors were encountered: