diff --git a/src/context/context.ts b/src/context/context.ts index eb7f53c..5bf69bc 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -286,13 +286,35 @@ export class WorkflowContext { body?: unknown; headers?: Record; } - ) { + ): Promise { const { url, method = "GET", body, headers = {} } = callSettings; const result = await this.addStep( - new LazyCallStep(stepName, url, method, body, headers ?? {}) + new LazyCallStep(stepName, url, method, body, headers ?? {}) ); + // + // if you transition to upstash/workflow from upstash/qstash, + // the out field in the steps will be the body of the response. + // we need to handle them explicitly here + if (typeof result === "string") { + try { + const body = JSON.parse(result); + return { + status: -1, + header: {}, + body, + }; + } catch { + return { + status: -1, + header: {}, + body: result, + }; + } + } + // + try { return { ...result,