ui / patches / zod@4.6.5.patchmain at d68d7e1
diff --git a/v4/core/errors.cjs b/v4/core/errors.cjs
index 0f2cc5a..50e4d5e 100644
--- a/v4/core/errors.cjs
+++ b/v4/core/errors.cjs
@@ -63,7 +63,19 @@ const initializer = (inst, def) => {
Object.defineProperty(inst, "issues", _issuesDesc);
// Clear the shared slot; a retained `value` pins the last error's issues.
_issuesDesc.value = undefined;
- Object.defineProperty(inst, "message", _messageDesc);
+ // PATCHED (iterate): materialize the message as an own data property at
+ // construction instead of installing the shared lazy accessor. The lazy
+ // getter leaves the Error's internal message slot empty, so structuredClone
+ // and Cloudflare Workers RPC serialize the error with NO message — callers
+ // across a DO/RPC hop saw bare "ZodError" instead of the validation issues.
+ // Eager stringify restores zod <=4.4 behavior; the cost lands on failure
+ // paths only.
+ Object.defineProperty(inst, "message", {
+ value: JSON.stringify(def, util.jsonStringifyReplacer, 2),
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ });
/* `toString` lives as a non-enumerable lazy getter on the shared
* prototype; on first access it caches a per-instance closure so
* detached usage still works. */
diff --git a/v4/core/errors.js b/v4/core/errors.js
index 587a0ca..7ecbb46 100644
--- a/v4/core/errors.js
+++ b/v4/core/errors.js
@@ -32,7 +32,19 @@ const initializer = (inst, def) => {
Object.defineProperty(inst, "issues", _issuesDesc);
// Clear the shared slot; a retained `value` pins the last error's issues.
_issuesDesc.value = undefined;
- Object.defineProperty(inst, "message", _messageDesc);
+ // PATCHED (iterate): materialize the message as an own data property at
+ // construction instead of installing the shared lazy accessor. The lazy
+ // getter leaves the Error's internal message slot empty, so structuredClone
+ // and Cloudflare Workers RPC serialize the error with NO message — callers
+ // across a DO/RPC hop saw bare "ZodError" instead of the validation issues.
+ // Eager stringify restores zod <=4.4 behavior; the cost lands on failure
+ // paths only.
+ Object.defineProperty(inst, "message", {
+ value: JSON.stringify(def, util.jsonStringifyReplacer, 2),
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ });
/* `toString` lives as a non-enumerable lazy getter on the shared
* prototype; on first access it caches a per-instance closure so
* detached usage still works. */