eLife tech discussion
This gist demonstrates a problem with IndexedDB & Promises in Firefox which makes using IndexedDB very unergonomic in some cases in Firefox.
The test below reads, updates & writes a counter value to an IndexedDB database 10 times in the same transaction and then prints the result. To make the code easier to read, it uses async + await, which requires converting the IndexedDB requests (
IDBRequest objects) to promises with a simple helper.
In Chrome, multiple promise callbacks can be executed with auto-committing an IDB transaction, allowing read-modify-write steps to work. In Firefox however, the IDB transaction gets auto-committed before the promise callback is fired, which means that read-modify-write operations have to use callbacks rather than promises.
Then in the VM:
|(h) ~/h/r/h > curl -I 'https://h.readthedocs.io/en/latest/api/'|
|HTTP/1.1 200 OK|
|Server: nginx/1.10.0 (Ubuntu)|
|Date: Tue, 13 Jun 2017 13:20:52 GMT|
|Last-Modified: Mon, 05 Jun 2017 09:11:35 GMT|
|diff --git a/src/sidebar/frame-sync.js b/src/sidebar/frame-sync.js|
|index 8a80563..6a505d7 100644|
|@@ -2,6 +2,7 @@|
|var events = require('./events');|
|var bridgeEvents = require('../shared/bridge-events');|
|+var memoize = require('./util/memoize');|
|var metadata = require('./annotation-metadata');|