3

jax webGLフレームワークでindexedDBを使用しようとしていますが、何らかの理由でsetVersionが機能していません。

これが関連するコーヒースクリプトです

if @indexedDB and @objectStore and @key
  idb_request = indexedDB.open @indexedDB
  idb_request.onsuccess = (e) =>
    idb = e.target.result

    if idb.objectStoreNames.contains @objectStore
      store = idb.transaction([@objectStore], IDBTransaction.READ_WRITE).objectStore(@objectStore)

    else

      console.log idb.version # => ""

      version_request = idb.setVersion(0.1)
      version_request.onblocked = (e) -> console.log e #=> this one fires
      version_request.onerror = (e) -> console.log e
      version_request.onsuccess = (e) -> console.log e
      version_request.onfailure = (e) -> console.log e

  idb_request.onerror = (e) -> console.log "ERROR: Unable to open indexedDB"

...

起動するバージョンリクエストに添付されている唯一のハンドラーはonblockedですが、リクエストがブロックされることの意味や、なぜこれが発生するのかさえわかりません...

バージョンリクエストがブロックされるのはなぜですか?

4

2 に答える 2

1

IndexedDB での開発時にデータベース接続を開いたままにする 2 つの一般的な方法を次に示します。

1) 複数のタブを開きます。

2) 誤ってデータベースを 2 回開いた。

于 2011-12-08T03:59:48.960 に答える
1

IndexedDB 仕様によるとblocked、バージョン変更要求が行われている間にデータベース接続がまだ開いている場合、イベントが送信される可能性があります。参照: http://www.w3.org/TR/IndexedDB/#version_change-transaction-steps

仕様のテキストは次のとおりです。

3. If running asynchronously and any of the connections in openDatabases are still not closed, queue up a blocked event for the request.

FWIW: この問題を Jax で再現できませんでした。不可能だとは言い切れませんが、現時点ではフレームワークのバグではないようです。対応する Jax の問題は次のとおりです: https://github.com/sinisterchipmunk/jax/issues/37

于 2011-12-08T02:37:28.777 に答える