Closed crishoj closed 1 week ago
The Typebox cleaner mutates the cleaned value:
Clean is a mutable operation. To avoid mutation, Clone the value first.
if (IsSchema(additionalProperties) && Check(additionalProperties, references, value[key])) { value[key] = Visit(additionalProperties, references, value[key]); continue; } delete value[key];
Therefore, it can break type-safety and lead to subtle bugs (and poor DX) when long-lived server objects are used in responses.
This proposed fix here is to use structuredClone() on the response body before cleaning.
structuredClone()
Fixes #897
🙏
The Typebox cleaner mutates the cleaned value:
Therefore, it can break type-safety and lead to subtle bugs (and poor DX) when long-lived server objects are used in responses.
This proposed fix here is to use
structuredClone()
on the response body before cleaning.Fixes #897