Commit Graph

4 Commits (c88381efe3c695b4dbcbdf837e6fe9ae5fc81dee)

Author SHA1 Message Date
Daniel Gasienica c88381efe3 Use `async` / `await` to improve readability 7 years ago
Daniel Gasienica 2642844c27 Rewrite migration 17 without `idb`
We ran into issues when doing async operations inside of an IndexedDB
`onupgradeneeded` handler. The errors were ‘The transaction is not active’ or
‘Transaction has finished’. The following documentation confirmed that
transactions are committed/terminated when control returns to the event loop:

Spec
- https://www.w3.org/TR/IndexedDB/#transaction-lifetime-concept
- https://www.w3.org/TR/IndexedDB/#upgrade-transaction-construct

Stack Overflow
- https://stackoverflow.com/a/11059085
- https://stackoverflow.com/a/27338944

Since the initial database migration is so critical, I decided to avoid `idb`
with promise support for IndexedDB for now, but will reconsider using it for
other tasks in the future to improve readability of IndexedDB code.
7 years ago
Daniel Gasienica 5d927b73e6 Use `while` loop for IDB cursor iteration
Previously, I messily combined promises and callbacks because I thought we
were affected by the microtask issue:
https://github.com/gasi/idb#iteratecursor--iteratekeycursor

ESLint’s `more/no-then` encouraged me to revisit this and it works as expected.
7 years ago
Daniel Gasienica 182e6ffe10 Add version 17 migration 7 years ago