Bug 83498 - [Debugger] IndexedDB: setVersion success event can be dispatched before handler is assigned
Summary: [Debugger] IndexedDB: setVersion success event can be dispatched before handl...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-09 12:38 PDT by Joshua Bell
Modified: 2013-04-11 09:14 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Bell 2012-04-09 12:38:54 PDT
Rough sketch of repro:

(1) Start up a worker that opens a DB connection. It should have an onversionchange handler that calls db.close immediately, e.g.

self.webkitIndexedDB.open('db').onsuccess = function (e) {
  self.db = e.target.result;
  self.db.onversionchange = function () { db.close(); };
};

(2) Once the worker is holding the connection open, from the window open another connection and start a version change transaction:

window.webkitIndexedDB.open('db').onsuccess = function (e) {
  window.db = e.target.result;
  var request = window.db.setVersion('1');
  debugger;
  request.onsuccess = function () { console.log("called!"); };
};

If a debugger is active (or if the stars align correctly), then at the "debugger" line:

* The worker's db.close() call occurs
* IDBDatabase::close() calls IDBDatabaseBackendImpl::close()
* IDBDatabaseBackendImpl::close() calls IDBDatabaseBackendImpl::processPendingCalls()
* The pending SetVersion request is dequeued, and the IDBTransactionBackendImpl created
* The transaction starts synchronously
* The the transaction executes the version number change step, which calls IDBCallbacks::onSuccess(transaction)
* This is implemented by IDBRequest::onSuccess(transaction), which calls enqueueEvent() with a "success" event
* The event is dispatched - and there is no "success" handler, so it's a no-op
* At the end of the dispatch logic, the IDBTransactionBackendImpl is notified that the task has been processed.
* No additional tasks have been scheduled for the IDBTransactionBackendImpl so it commits
Comment 1 Joshua Bell 2012-04-09 15:55:24 PDT
This appears to specific to the debugger - the dispatch is occurring as a result of the call from the worker, despite the main JS execution context (terminology?) of the window being halted.

dgrogan@ thinks this may be related to https://bugs.webkit.org/show_bug.cgi?id=60790 and aklein@/rafaelw@ indicate they ran into the same issue with Mutation Observers and the debugger.

un-assigning as I don't think we need to tackle this immediately.