Skip to content

Commit

Permalink
Make transactions inactive during clone (#310)
Browse files Browse the repository at this point in the history
To avoid side effects from getters during cloning operations (part of put/add/update calls), make transactions temporarily inactive.

Implemented in Blink, pending implementation in Gecko.
  • Loading branch information
inexorabletash authored Nov 26, 2019
1 parent 7d425a9 commit 95d8712
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2983,7 +2983,7 @@ To <dfn>add or put</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|,

1. Let |targetRealm| be a user-agent defined [=Realm=].

1. Let |clone| be a [=clone=] of |value| in |targetRealm|.
1. Let |clone| be a [=clone=] of |value| in |targetRealm| during |transaction|.
Rethrow any exceptions.

<details class=note>
Expand Down Expand Up @@ -4680,7 +4680,7 @@ invoked, must run these steps:

1. Let |targetRealm| be a user-agent defined [=Realm=].

1. Let |clone| be a [=clone=] of |value| in |targetRealm|.
1. Let |clone| be a [=clone=] of |value| in |targetRealm| during |transaction|.
Rethrow any exceptions.

<details class=note>
Expand Down Expand Up @@ -5528,8 +5528,7 @@ To <dfn>abort an upgrade transaction</dfn> with |transaction|, run these steps:

<div class=algorithm>

To <dfn>fire a success event</dfn> at a |request|,
the implementation must run these steps:
To <dfn>fire a success event</dfn> at a |request|, run these steps:

1. Let |event| be the result of [=creating an event=] using {{Event}}.

Expand Down Expand Up @@ -5568,8 +5567,7 @@ the implementation must run these steps:

<div class=algorithm>

To <dfn>fire an error event</dfn> at a |request|,
the implementation must run these steps:
To <dfn>fire an error event</dfn> at a |request|, run these steps:

1. Let |event| be the result of [=creating an event=] using {{Event}}.

Expand Down Expand Up @@ -5621,13 +5619,23 @@ the implementation must run these steps:

<div class=algorithm>

To make a <dfn>clone</dfn> of |value| in |targetRealm|,
the implementation must run these steps:
To make a <dfn>clone</dfn> of |value| in |targetRealm| during |transaction|,
run these steps:

1. [=/Assert=]: |transaction|'s [=transaction/state=] is [=transaction/active=].

1. Set |transaction|'s [=transaction/state=] to [=transaction/inactive=].

<aside class=note>
The [=/transaction=] is made [=transaction/inactive=] so that getters or other side effects triggered by the cloning operation are unable to make additional requests against the transaction.
</aside>

1. Let |serialized| be [=?=] <a abstract-op>StructuredSerializeForStorage</a>(|value|).

1. Let |clone| be [=?=] <a abstract-op>StructuredDeserialize</a>(|serialized|, |targetRealm|).

1. Set |transaction|'s [=transaction/state=] to [=transaction/active=].

1. Return |clone|.

</div>
Expand Down Expand Up @@ -6815,6 +6823,7 @@ For the revision history of the second edition, see [that document's Revision Hi
* Removed handling for nonstandard `lastModifiedDate` property of {{File}} objects. ([Issue #215](https://github.com/w3c/IndexedDB/issues/215))
* Remove escaping {{IDBKeyRange/includes()}} method. ([Issue #294](https://github.com/w3c/IndexedDB/issues/294))
* Restrict array keys to [=/Array exotic objects=] (i.e. disallow proxies). ([Issue #309](https://github.com/w3c/IndexedDB/issues/309])
* Transactions are now temporarily made inactive during clone operations.

<!-- ============================================================ -->
# Acknowledgements # {#acknowledgements}
Expand Down

0 comments on commit 95d8712

Please sign in to comment.