Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions examples/ci/app/ci/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ export const initiateTest = async (params: Pick<TestConfig, "route">) => {
try {
await redis.checkRedisForResults(route, randomTestId, expectedCallCount, expectedResult)
} catch (error) {
try {
const logs = await qstash.getWorkflowLogs(workflowRunId)
console.error("Test Failed. Logs of the started workflow:", JSON.stringify(logs, null, 2))
} catch (error) {
console.error("Failed to get workflow logs:", error)
}
console.error("Test Failed. no results found.")
throw error
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"typescript-eslint": "^8.18.0"
},
"dependencies": {
"@upstash/qstash": "^2.8.4"
"@upstash/qstash": "2.9.0-rc"
},
"directories": {
"example": "examples"
Expand Down
12 changes: 1 addition & 11 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,7 @@ export class Client {
private client: QStashClient;

constructor(clientConfig: ClientConfig) {
if (!clientConfig?.token) {
console.error(
"QStash token is required for Upstash Workflow!\n\n" +
"To fix this:\n" +
"1. Get your token from the Upstash Console (https://console.upstash.com/qstash)\n" +
"2. Initialize the workflow client with:\n\n" +
" const client = new Client({\n" +
" token: '<YOUR_QSTASH_TOKEN>'\n" +
" });"
);
}
// TODO: add warning back
this.client = new QStashClient(clientConfig);
}

Expand Down
27 changes: 17 additions & 10 deletions src/serve/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
verifyRequest,
} from "../workflow-requests";
import { DisabledWorkflowContext } from "./authorization";
import { getHandlersForRequest } from "./multi-region/handlers";
import {
AUTH_FAIL_MESSAGE,
createResponseData,
Expand Down Expand Up @@ -61,10 +62,8 @@ export const serveBase = <
// Prepares options with defaults if they are not provided.

const {
qstashClient,
initialPayloadParser,
url,
receiver,
failureFunction,
baseUrl,
env,
Expand Down Expand Up @@ -100,12 +99,20 @@ export const serveBase = <
middlewareManager.dispatchDebug.bind(middlewareManager)
);

// validation & parsing to get isFirstInvocation early
const { isFirstInvocation, workflowRunId, unknownSdk } = validateRequest(request);

// Get the appropriate handlers based on region
const regionHeader = request.headers.get("upstash-region");
const { client: regionalClient, receiver: regionalReceiver } = getHandlersForRequest(
internal.qstashHandlers,
regionHeader,
isFirstInvocation
);

// get payload as raw string
const requestPayload = (await getPayload(request)) ?? "";
await verifyRequest(requestPayload, request.headers.get("upstash-signature"), receiver);

// validation & parsing
const { isFirstInvocation, workflowRunId, unknownSdk } = validateRequest(request);
await verifyRequest(requestPayload, request.headers.get("upstash-signature"), regionalReceiver);

middlewareManager.assignWorkflowRunId(workflowRunId);
await middlewareManager.dispatchDebug("onInfo", {
Expand All @@ -118,7 +125,7 @@ export const serveBase = <
isFirstInvocation,
unknownSdk,
workflowRunId,
requester: qstashClient.http,
requester: regionalClient.http,
messageId: request.headers.get("upstash-message-id")!,
dispatchDebug: middlewareManager.dispatchDebug.bind(middlewareManager),
});
Expand All @@ -144,7 +151,7 @@ export const serveBase = <
const failureCheck = await handleFailure<TInitialPayload>({
request,
requestPayload,
qstashClient,
qstashClient: regionalClient,
initialPayloadParser,
routeFunction,
failureFunction,
Expand Down Expand Up @@ -181,7 +188,7 @@ export const serveBase = <

// create context
const workflowContext = new WorkflowContext<TInitialPayload>({
qstashClient,
qstashClient: regionalClient,
workflowRunId,
initialPayload: initialPayloadParser(rawInitialPayload),
headers: recreateUserHeaders(request.headers as Headers),
Expand Down Expand Up @@ -219,7 +226,7 @@ export const serveBase = <
const callReturnCheck = await handleThirdPartyCallResult({
request,
requestPayload: rawInitialPayload,
client: qstashClient,
client: regionalClient,
workflowUrl,
telemetry,
middlewareManager,
Expand Down
Loading
Loading