-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Client sees "Task <id> failed" instead of the real error/result on failed tasks #1922
Copy link
Copy link
Open
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingSomething isn't workingfix proposedBot has a verified fix diff in the commentBot has a verified fix diff in the commentgood first issueGood for newcomers - can be tackled without deep knowledge of the codebaseGood for newcomers - can be tackled without deep knowledge of the codebaseready for workEnough information for someone to start working onEnough information for someone to start working on
Metadata
Metadata
Assignees
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingSomething isn't workingfix proposedBot has a verified fix diff in the commentBot has a verified fix diff in the commentgood first issueGood for newcomers - can be tackled without deep knowledge of the codebaseGood for newcomers - can be tackled without deep knowledge of the codebaseready for workEnough information for someone to start working onEnough information for someone to start working on
I initially started with a PR (the fix itself is small), but the returned shape changes for existing consumers, so wanted to raise it first. I would be happy to work on this PR.
For reference, we experienced this issue while adding support for long-running async tasks for Actors in Apify MCP server - see failed task do not return results and apify/apify-mcp-server#685 (comment)"
Describe the bug
From the spec:
So when a task fails, we're blind to the real error - the client just gets
Task <id> failed.When a task-augmented request reaches
failedstatus,TaskManager.requestStreamdoesn't calltasks/resultit just yields a hardcodedProtocolError(InternalError, "Task <id> failed"). So whatever the handler stored (e.g.{ isError: true, content: [...] }) is unreachable.To Reproduce
storeTaskResult(taskId, 'failed', { content: [...], isError: true }).client.experimental.tasks.requestStream(...)with thetaskoption set.ProtocolError("Task <id> failed")Expected behavior
requestStreamshould calltasks/resultonfailedthe same way it does oncompleted, and yield whatever comes back:{ type: 'result', result }for a storedResult, or{ type: 'error', error }(with the real code/message/data preserved) iftasks/resultreturns a JSON-RPC error.cancelledcan stay synthesized since nothing is stored for it.Logs
N/A - deterministic from the code path above.
Additional context
This helper is shared between the client and server experimental tasks modules, so both
ExperimentalClientTasks.requestStreamandExperimentalServerTasks.requestStreamare affected.