Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
terion-name opened this issue Mar 15, 2025 · 0 comments
Open

Comments

@terion-name
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant