Javascript 狩猎旅行——”;TransactionActiveError“;使用Facebook IndexeDbPolyFill

Javascript 狩猎旅行——”;TransactionActiveError“;使用Facebook IndexeDbPolyFill,javascript,safari,mobile-safari,indexeddb,polyfills,Javascript,Safari,Mobile Safari,Indexeddb,Polyfills,我们正在使用以允许在Safari/Mobile Safari中使用IndexedDB API。但是,我们在尝试更新记录时遇到了“TransactionActiveError”-错误源于Polyfill.js文件的第1567行:如果(!me.\u active)抛出新的util.error(“TransactionActiveError”) 这里有一个简单的例子。只需添加Facebook Polyfill脚本标记引用并在Safari中运行: var db; var request = indexe

我们正在使用以允许在Safari/Mobile Safari中使用IndexedDB API。但是,我们在尝试更新记录时遇到了“TransactionActiveError”-错误源于Polyfill.js文件的第1567行:
如果(!me.\u active)抛出新的util.error(“TransactionActiveError”)

这里有一个简单的例子。只需添加Facebook Polyfill脚本标记引用并在Safari中运行:

var db;
var request = indexedDB.open("polyfillTest");

request.onupgradeneeded = function () {
    // The database did not previously exist, so create object stores and indexes.
    db = request.result;
    var store = db.createObjectStore("books", {keyPath: "isbn"});
    var titleIndex = store.createIndex("by_title", "title", {unique: true});
    var authorIndex = store.createIndex("by_author", "author");

    // Populate with initial data.
    store.put({title: "Quarry Memories", author: "Fred", isbn: 123456});
    store.put({title: "Water Buffaloes", author: "Fred", isbn: 234567});
    store.put({title: "Bedrock Nights", author: "Barney", isbn: 345678});

    updateItem(store);
};

request.onsuccess = function () {
    db = request.result;
};

function updateItem(store) {
    var request = store.get(123456);

    request.onsuccess = function () {
        var book = request.result;
        book.title = "New Title";
        book.author = "New Author";

        var updateRequest = store.put(book);
        updateRequest.onsuccess = function (evt) {
            console.log("Book updated successfully.");
        };
        updateRequest.onerror = function (evt) {
            console.error("Book could not be updated.");
        };
    };
}
感谢您的帮助


非常感谢

在发布该引用之前,事务通常保持活动状态。因此,我认为您的交易是自动提交的

我怀疑这可能与您重新使用
versionchange
事务进行
put
get
有关。在经历了许多关于这个问题的头痛之后,在我的工作中,我选择了一种模式,在尝试在同一家商店上进行CRUD操作之前,我会选择这种模式


我无法完全解释原因,但基于多年的挫折,保持长期版本更改似乎是个坏主意。

同意。没有理由对db op请求使用versionchange事务。