Skip to content
Myr

fix: Set finalization can get stuck in a loop, fixes #628

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent b1c6a8e · Browse files · 2 files+32 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+32 added−3 removed

  • tests:+24 added−0 removed
  • other:+8 added−3 removed

2 files+32 added−3 removed

modified:__tests__/regressions.js+24 added
modified:src/core/finalize.ts+8 added-3 removed
85 unmodified lines
86 // For ES5, create a good copy from the draft first, with added keys and without deleted keys.87 state.type_ === ProxyTypeES5Object || state.type_ === ProxyTypeES5Array88 ? (state.copy_ = shallowCopy(state.draft_))89 : state.copy_90 // finalize all children of the copy91 each(result as any, (key, childValue) =>92 finalizeProperty(rootScope, state, result, key, childValue, path)90 // Finalize all children of the copy91 // For sets we clone before iterating, otherwise we can get in endless loop due to modifying during iteration, see #62892 // Although the original test case doesn't seem valid anyway, so if this in the way we can turn the next line93 // back to each(result, ....)94 each(95 state.type_ === ProxyTypeSet ? new Set(result) : result,96 (key, childValue) =>97 finalizeProperty(rootScope, state, result, key, childValue, path)98 )99 // everything inside is frozen, we can freeze here100 maybeFreeze(rootScope, result, false)101 // first time finalizing, let's create those patches
60 unmodified lines