Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prevent a Deferred from firing twice when an IndexedDB version change…

… is blocked.

R=nweiz
DELTA=10  (8 added, 0 deleted, 2 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=5769


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2271 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
commit 00c7300970335054472a0757b61e5caf02f0e8c5 1 parent b1a9a81
tbreisacher@google.com authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 closure/goog/db/indexeddb.js
View
12 closure/goog/db/indexeddb.js
@@ -165,10 +165,18 @@ goog.db.IndexedDb.prototype.setVersion = function(version) {
d.callback(new goog.db.Transaction(ev.target.result));
};
request.onerror = function(ev) {
- d.errback(new goog.db.Error(ev.target.errorCode, 'setting version'));
+ // If a version change is blocked, onerror and onblocked may both fire.
+ // Check d.hasFired() to avoid an AlreadyCalledError.
+ if (!d.hasFired()) {
+ d.errback(new goog.db.Error(ev.target.errorCode, 'setting version'));
+ }
};
request.onblocked = function(ev) {
- d.errback(new goog.db.Error.VersionChangeBlockedError());
+ // If a version change is blocked, onerror and onblocked may both fire.
+ // Check d.hasFired() to avoid an AlreadyCalledError.
+ if (!d.hasFired()) {
+ d.errback(new goog.db.Error.VersionChangeBlockedError());
+ }
};
return d;
};
Please sign in to comment.
Something went wrong with that request. Please try again.