Closed Bug 1192160 Opened 9 years ago Closed 9 years ago

IndexedDB transactions should not be active after Promise#then()

Categories

(Core :: Storage: IndexedDB, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1179909

People

(Reporter: timdream, Unassigned)

References

Details

According to spec [1] at step 8, this [2] should throw an exception:

[1] http://w3c.github.io/IndexedDB/#dom-idbdatabase-transaction
[2] https://github.com/mozilla-b2g/gaia/blob/master/apps/keyboard/js/shared/promise_storage.js#L87-L97

Chrome has the same issue at [3]

[3] https://code.google.com/p/chromium/issues/detail?id=457409

Obviously fixing this bug will break [1] so we would have to patch Gaia first. Or, alternatively, we could work with Chrome and retro-update the spec ...

I don't know if IDBRequest#onsuccess behaves the same way on Gecko. According to @jaffathecake it is on Chrome. Probably worth a spec update too.
I guess updating the spec for this would be pretty difficult. What would it be? A microtask that queues a microtask?
However, I'd like to see the spec changed for the success event. http://w3c.github.io/IndexedDB/#dfn-fire-a-success-event step 4 - I'd like to see this queued as a microtask.
(In reply to Jake Archibald from comment #1)
> I guess updating the spec for this would be pretty difficult. What would it
> be? A microtask that queues a microtask?

I am more leaning toward updating the spec than fixing this bug in Gecko/Blink, as that might very well break the Web.

I, however, will fix Gaia anyway first.
Bug 1179909 is going to change the behavior so that every microtask is its own transition scope.  That may not be the behavior we ultimately want, but it's easier to make things more lax than more stringent.
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #4)
> Bug 1179909 is going to change the behavior so that every microtask is its
> own transition scope.  That may not be the behavior we ultimately want, but
> it's easier to make things more lax than more stringent.

Does that means this bug is accidentally fixed by bug 1179909? I am seeing PromiseStorage failed as expected at [1] with error [2] when I update the Gecko build.

[1] https://github.com/mozilla-b2g/gaia/blob/84fc50c0b4da86de68ed82022b5f05c9968da0e5/apps/keyboard/js/shared/promise_storage.js#L87-L97

[2] DOMException [InvalidStateError: "An attempt was made to use an object that is not, or is no longer, usable"
code: 11
nsresult: 0x8053000b
location: app://keyboard.gaiamobile.org/js/shared/promise_storage.js:129] 
    at PromiseStorage.prototype.getItem/< (app://keyboard.gaiamobile.org/js/shared/promise_storage.js:138:1)

We should broadcast this Gecko change more widely on dev-gaia if so.
Flags: needinfo?(khuey)
Or, to align with the Chrome resolution on [1] today, we should WONTFIX this bug, and revert the change done on bug 1179909 to this pattern, and probably INVALID bug 1193136 too if that's really not necessary.

[1] https://code.google.com/p/chromium/issues/detail?id=457409
(In reply to Tim Guan-tin Chien [:timdream] (slow response; please ni? to queue) from comment #5)
> (In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #4)
> > Bug 1179909 is going to change the behavior so that every microtask is its
> > own transition scope.  That may not be the behavior we ultimately want, but
> > it's easier to make things more lax than more stringent.
> 
> Does that means this bug is accidentally fixed by bug 1179909? I am seeing
> PromiseStorage failed as expected at [1] with error [2] when I update the
> Gecko build.
> 
> [1]
> https://github.com/mozilla-b2g/gaia/blob/
> 84fc50c0b4da86de68ed82022b5f05c9968da0e5/apps/keyboard/js/shared/
> promise_storage.js#L87-L97
> 
> [2] DOMException [InvalidStateError: "An attempt was made to use an object
> that is not, or is no longer, usable"
> code: 11
> nsresult: 0x8053000b
> location: app://keyboard.gaiamobile.org/js/shared/promise_storage.js:129] 
>     at PromiseStorage.prototype.getItem/<
> (app://keyboard.gaiamobile.org/js/shared/promise_storage.js:138:1)
> 
> We should broadcast this Gecko change more widely on dev-gaia if so.

It's not accidentally fixed, it's intentionally fixed.

We may change this behavior in the future.  Having a single queue of microtasks and adding transaction committing to the end of the queue seems to be relatively sensible.
Flags: needinfo?(khuey)
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #7)
> It's not accidentally fixed, it's intentionally fixed.
> 
> We may change this behavior in the future.  Having a single queue of
> microtasks and adding transaction committing to the end of the queue seems
> to be relatively sensible.

Alright, let's file a new bug if we want to change the behavior. I am going to send an e-mail to dev-gaia so other Gaia part can be updated accordingly.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.