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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

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.

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

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.

3 participants