-
Notifications
You must be signed in to change notification settings - Fork 44
feat: cancellable Actor run #228
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
base: master
Are you sure you want to change the base?
Conversation
We could add a test to check that cancelled requests don't send any response. Now is only tested than request is cancelled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I already menitoned in person, please change the Actor in tests to either apify/python-example
or apify/rag-web-browser
. These are already on staging and I would prefer to not add a new Actor there to our testing suite. If that is not possible we can include this Actor (if truly needed). Otherwise LGTM, thank you 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @MQ37. I also left a couple of comments that should be taken care of.
It should also be possible to send the cancel/notification to actor-mcp, but let’s not complicate this issue with that.
Please create a new issue so we don’t forget.
src/tools/actor.ts
Outdated
// Start the actor run but don't wait for completion | ||
// Check if already aborted | ||
if (abortSignal?.aborted) { | ||
throw new Error('Operation cancelled'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are throwing exception that is caugth locally
// Create abort promise that handles both API abort and race rejection | ||
const abortPromise = async () => new Promise<never>((_, reject) => { | ||
abortSignal?.addEventListener('abort', async () => { | ||
// Abort the actor run via API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the spec: Both parties SHOULD log cancellation reasons for debugging
So should we add an INFO log here: MCP client requested cancellation, actorName ....
I also need to check if the Actorized MCP server receives a cancel notification. I could try to make some tests, but it can be hard/impossible with actual source code. |
Closes: #160
Tested in:
I tried to write a test using manually sending a cancel notification, but I need a request ID, and I don't know where to find it because it's managed internally in the MCP client.