fix: throw on reads of a revoked Map or Set draft (#1298)
Landed as 8848a5b
Once produce or finishDraft returns, the draft is revoked and any further use is meant to fail loudly. Object and array drafts get that from Proxy.revocable, but Map and Set drafts are subclasses guarded by a manual revoked_ flag, and several read paths never checked it: const map = new Map([["a", 1]]) let draft produce({map}, d => { draft = d.map }) draft.has("a") // true, should throw draft.size // 1, should throw [...draft.keys()] // ["a"], should throw draft.get("a") // throws, as expected DraftSet.has already calls assertUnrevoked, so the same read on a Set draft throws while the Map one silently returns stale data. This is the exact async-leak case error 3 is meant to catch, so it should not depend on which accessor the caller happens to use. Add assertUnrevoked to DraftMap.has, DraftMap.size, DraftMap.keys, DraftMap.forEach and DraftSet.size. DraftMap.values and DraftMap.entries build on keys, so they now fail when they are called rather than on the first next(). Nothing outside the plugin reads these accessors after revocation, and the full suite is unchanged.