Skip to content

fix(finalize): finalize entries in replacement Sets - #1375

Open
Twiink wants to merge 1 commit into
immerjs:mainfrom
Twiink:fix/set-finalization
Open

Twiink wants to merge 1 commit into
immerjs:mainfrom
Twiink:fix/set-finalization

Conversation

@Twiink

@Twiink Twiink commented Nov 20, 2026

Copy link
Copy Markdown

Returning a new Set containing draft children leaves revoked proxies in the result. For example, produce({item: {id: 1}}, draft => new Set([draft.item])) produces a Set that throws when inspected and also contains an extra finalized copy. The same occurs when the replacement Set is nested in a returned object.

Rebuild plain Sets from a snapshot during replacement-value finalization. This removes the original draft entries and adds finalized values in the original insertion order, including primitive and foreign-scope entries.

Four regression cases fail on unchanged main; four empty/primitive controls pass. With the fix: 4221 source tests and 3670 production-build tests pass (8 existing skips each), all JS/DTS builds pass, Flow reports no errors, and six ESM/CJS consumers verify order, identity and absence of drafts with autoFreeze on/off.

Prepared and verified with OpenAI Codex assistance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant