trigger.dev icon indicating copy to clipboard operation
trigger.dev copied to clipboard

bug: nor onFailure nor handleError are triggered when task times out

Open terion-name opened this issue 10 months ago • 0 comments

Provide environment information

System: OS: macOS 15.3.2 CPU: (10) arm64 Apple M1 Max Memory: 511.00 MB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 23.5.0 - /opt/homebrew/bin/node Yarn: 4.5.2 - /opt/homebrew/bin/yarn npm: 11.0.0 - /opt/homebrew/bin/npm bun: 1.2.4 - ~/.bun/bin/bun

Describe the bug

When maxDuration hits onFailure handler is not called (handleError also)

Sample:

const failed = async (payload: z.infer<typeof sendMessageTask>) => {
	console.log("Failed to upload media", payload);
	await MessageEntity.update(
		{ id: payload.message.id },
		{
			content: payload.message.content || "",
			status: MessageEntity.STATUS_FAILED,
		},
	);
	await chatwoot.triggerUpdate(payload.message.id);
};

export const uploadMedia = task<
	string,
	z.infer<typeof sendMessageTask>
>({
	id: "upload-media",
	maxDuration: 120,
	onFailure: async (payload, error, params) => await failed(payload),
	handleError: async (payload, error, params) => await failed(payload),
	run: async (payload, ctx) => {
             ...

No log entry, no api call

Reproduction repo

see sample

To reproduce

const failed = async (payload) => {
	console.log("Failed"); // or logger.log
};

export const uploadMedia = task<
	string,
	any
>({
	id: "long-task",
	maxDuration: 10,
	onFailure: async (payload, error, params) => await failed(payload),
	handleError: async (payload, error, params) => await failed(payload),
	run: async (payload, ctx) => {  await new Promise(r => setTimeout(r, 30000)) }
})

Additional information

No response

terion-name avatar Mar 15 '25 20:03 terion-name