diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 84f273a..33f2b52 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -308,7 +308,7 @@ jobs: working-directory: examples/nextjs - name: Run local tests - run: bun test . + run: node ci.mjs working-directory: examples/nextjs nextjs-pages-local-build: diff --git a/examples/nextjs/ci.mjs b/examples/nextjs/ci.mjs new file mode 100644 index 0000000..7ecbf08 --- /dev/null +++ b/examples/nextjs/ci.mjs @@ -0,0 +1,32 @@ +// this file is need for the Node 18 test + +import { Client } from "@upstash/qstash" +import { serve } from "@upstash/workflow/nextjs" + +const qstashClient = new Client({ + baseUrl: "https://workflow-tests.requestcatcher.com/", + token: "mock" +}) + +const { POST: serveHandler } = serve( + async (context) => { + await context.sleep("sleeping", 10) + }, { + qstashClient, + receiver: undefined + } +) + +const request = new Request("https://workflow-tests.requestcatcher.com/") +const response = await serveHandler(request) + +const status = response.status +const body = await response.text() + +if (status !== 500) { + throw new Error(`ci failed. incorrect status. status: ${status}, body: ${body}`) +} +if (body !== `{"error":"SyntaxError","message":"Unexpected token 'r', \\"request caught\\" is not valid JSON"}`) { + throw new Error(`ci failed. incorrect body. status: ${status}, body: ${body}`) +} +console.log(">>> CI SUCCESFUL") \ No newline at end of file diff --git a/examples/nextjs/ci.test.ts b/examples/nextjs/ci.test.ts index 7f94f13..fa85560 100644 --- a/examples/nextjs/ci.test.ts +++ b/examples/nextjs/ci.test.ts @@ -17,6 +17,8 @@ const { POST: serveHandler } = serve( } ) +console.log(process.versions.node.split('.').map(Number)); + describe("nextjs tests", () => { test("first invocation", async () => { const request = new Request("https://workflow-tests.requestcatcher.com/") diff --git a/src/context/auto-executor.ts b/src/context/auto-executor.ts index 6a511ef..930fa52 100644 --- a/src/context/auto-executor.ts +++ b/src/context/auto-executor.ts @@ -529,5 +529,5 @@ const validateParallelSteps = (lazySteps: BaseLazyStep[], stepsFromRequest: Step */ const sortSteps = (steps: Step[]): Step[] => { const getStepId = (step: Step) => step.targetStep || step.stepId; - return [...steps].sort((step, stepOther) => getStepId(step) - getStepId(stepOther)); + return steps.toSorted((step, stepOther) => getStepId(step) - getStepId(stepOther)); };