Deep-clone json and context in init hooks (match searchParams)#871
Deep-clone json and context in init hooks (match searchParams)#871greymoth-jp wants to merge 2 commits into
Conversation
|
This regresses cyclic I verified this manually: the same snippet succeeds on I think the underlying leak is real, but deep-cloning arbitrary |
Deep-cloning json overflowed the stack for cyclic or very deep serializer input before stringifyJson ran. Revert json to a shallow clone (restoring main's behavior) and keep context deep-cloned, since that is what the cross-request leak fix was actually about. Drop the nested-json test and add a regression test for cyclic json with a custom stringifyJson and an init hook present.
|
You're right, deep-cloning Reverted |
cloneInitHookOptionsdeep-clonessearchParams(#861) andretryso init-hook mutations don't leak across requests, butjsonandcontextare still only shallow-cloned (one level). A nested mutation in abeforeRequesthook (e.g.options.json.meta.requestId = ...on a reusedjson: {meta: {}}) leaks into subsequent requests. Existing tests only cover top-level mutation, so it's undetected.#861 established the deep-clone-nested-init-hook-structures pattern for
searchParams;json/contextwere left behind. The fix applies the same isolation (+2 tests). Verified both ways: old leaks the nested mutation, fix isolates it; top-level, Date, and class-instance cases preserved, 0 regression.