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

context.cancel & rename errors & lazy fetch #8

Merged
merged 18 commits into from
Nov 20, 2024

Conversation

CahidArda
Copy link
Collaborator

@CahidArda CahidArda commented Oct 25, 2024

context.cancel

added method for canceling a worklfow with its context:

await context.cancel()

workflow status will appear as RUN_CANCELED in Upstash Console.

rename errors

renamed errors from QStashWorkflowAbort and QStashWorkflowError to WorkflowAbort and WorkflowError

lazy fetch

adds the lazy fetch feature.

  • if the workflow state grows larger than 3 Mb, QStash will start sending empty requests and SDK will fetch the state from QStash.

There is one case we can't handle right now: lazy fetch doesn't work with failureFunction. Lazy fetch doesn't become enabled. So the payload is delivered as it is. This means that your workflow can grow larger than 10Mb thanks to lazy fetch, but failureFunction won't work if this happens. edit: this issue was addressed in this PR.

initial payload is still accessible through context.initialPayload
run state would become run_success. now it becomes run_canceled
Copy link

linear bot commented Oct 25, 2024

@@ -25,3 +26,24 @@ export const makeGetWaitersRequest = async (
})) as Required<Waiter>[];
return result;
};

export const makeCancelRequest = async (requester: Client["http"], workflowRunId: string) => {
const result = (await requester.request({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does /v2/workflows/runs/ID retturns empty response on successfull cancellation? Don't we get any response?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it returns empty response.

@@ -383,6 +387,20 @@ export class WorkflowContext<TInitialPayload = unknown> {
}
}

/**
* Notify waiting workflow runs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this explanation should tell a bit more than the function signature itself. Since this is not trivial, can we give more explanation?

@@ -3,4 +3,4 @@ export * from "./context";
export * from "./types";
export * from "./logger";
export * from "./client";
export { QStashWorkflowError, QStashWorkflowAbort } from "./error";
export { WorkflowError, WorkflowAbort } from "./error";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we make a major release? If not maybe we should do something like this for consistency

export const QStashWorkflowError = WorkflowError

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be a major release.

currently it's 0.1.2, this will be 0.2.0

@fahreddinozcan
Copy link
Collaborator

There are some conflicts @CahidArda

@CahidArda
Copy link
Collaborator Author

conflicts fixed. @fahreddinozcan

@CahidArda
Copy link
Collaborator Author

lazy fetch will be updated with https://github.com/upstash/qstash-server/pull/423

src/workflow-parser.ts Outdated Show resolved Hide resolved
they are disabled because they are unreliable in CI. will run locally instead.
@buggyhunter buggyhunter merged commit 0d6ea11 into main Nov 20, 2024
17 checks passed
@buggyhunter buggyhunter deleted the DX-1279-context-cancel branch November 20, 2024 08:02
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

Successfully merging this pull request may close these issues.

4 participants