Skip to content

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

@terion-name

Description

@terion-name

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

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