Skip to content

[BUG] Zod issue during when scheduling a task via Typescript SDK #2491

@abhijit-hota

Description

@abhijit-hota

I have a task that can reschedule itself which looks like the following:

type InputType = { foo: string; bar: string };

export const myReschedulableTask = hatchet.task({
	name: "my_reschedulable_task",
	onEvents: ["schedule_trigger"],
	fn: async (input: InputType) => {
		const res = await myOperation(input);

		if (res?.rescheduleAt) {
			await myReschedulableTask
				.schedule(res.rescheduleAt, input, {
					additionalMetadata: {
						foo: input.foo,
						bar: input.bar,
					},
				})
				.then(() => {
					console.info(
						"Rescheduled my reschedulable task at %s",
						res.rescheduleAt.toISOString(),
					);
				})
				.catch((error) => {
					console.error(
						error,
						"Failed to reschedule my reschedulable task",
					);
				});
		}
	},
	executionTimeout: "5m",
});

async function myOperation(input: InputType): Promise<{ rescheduleAt: Date }> {
	// ...
}

This is the exact pattern I'm using to reschedule and it works fine locally with Hatchet Lite.

But after deploying the app which uses the cloud engine, I get this error:

TypeError: undefined is not an object (evaluating 'def.valueType._zod')
    at <anonymous> (/app/node_modules/zod/v4/core/schemas.cjs:1303:36)
    at anonymous (file:///app/node_modules/zod/v4/core/doc.cjs:23:40)
    at <anonymous> (/app/node_modules/zod/v4/core/schemas.cjs:936:23)
    at <anonymous> (/app/node_modules/zod/v4/core/parse.cjs:32:32)
    at <anonymous> (/app/node_modules/@hatchet-dev/typescript-sdk/v1/client/features/schedules.js:73:76)
    at <anonymous> (/app/node_modules/@hatchet-dev/typescript-sdk/v1/client/features/schedules.js:8:71)
    at new Promise (native:1:11)
    at <anonymous> (/app/node_modules/@hatchet-dev/typescript-sdk/v1/client/features/schedules.js:4:27)
    at <anonymous> (/app/node_modules/@hatchet-dev/typescript-sdk/v1/declaration.js:8:71)
    at new Promise (native:1:11)

Could this be a Zod version mismatch issue? We use Zod v4.1. I see that Hatchet SDK uses Zod v3.24 but the error has the /v4 path.

Environment

  • SDK: TypeScript v1.10.0
  • Runtime: Bun v1.2.21
  • Engine: Cloud

Expected behavior
No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions