Skip to content

zod v4: safeParse on invalid input throws error is not a function under compilePackages #4699

Description

@proggeramlug

Repro

package.json: { "perry": { "compilePackages": ["zod"], "allow": { "compilePackages": ["zod"] } } }

import { z } from "zod";
const r = z.object({ a: z.string() }).safeParse({ a: 123 });
console.log("success:", r.success);

Perry:

TypeError: error is not a function
    at <anonymous>

Node (--experimental-strip-types): success: false

The valid path is fine — z.object({a:z.string()}).parse({a:"hi"}) returns {a:"hi"} and matches Node (after #4697). This only fires on the validation-failure / issue-reporting path, where zod constructs a ZodError / formats issues. Something bound as error is being invoked as a function and is not callable (likely a ZodError constructor, an error-named export, or an issue-map/config().customError callback that resolved to a non-function across the perry.compilePackages module boundary).

Context

Follow-up to discussion #3438. Core object parsing fixed by #4697. This is the error/issue-construction path; the checks-path crash is tracked separately (#4698). Refs #793.

Next step: localize which error symbol is non-callable — core/errors.ts ($ZodError / $ZodRealError) and the config() error-map plumbing are the prime suspects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions