Skip to content

In server component on the vercel world, get stuck awaiting workflow's run.returnValue despite the workflow returning #618

Closed

Description

@remiconnesson

In server component on the vercel world, get stuck awaiting workflow's run.returnValue despite the workflow returning
This happens in the vercel world but not in development:

Reproduction

A minimal repro can be found here:
https://github.com/remiconnesson/repro-workflow-vercel-rsc-await-return-value

// app/workflows/test-workflow.ts
import { sleep } from "workflow";

export async function testWorkflow(input: string) {
  "use workflow";
  
  console.log("[testWorkflow] 1. Started with:", input);
  
  await sleep("2 seconds");
  
  console.log("[testWorkflow] 2. After sleep");
  
  return { message: `Hello ${input}`, timestamp: Date.now() };
}
// app/page.tsx
import { start } from "workflow/api";
import { testWorkflow } from "@/app/workflows/test-workflow";

export const dynamic = "force-dynamic"; // otherwise can't deploy because the build hangs on await and times out

export default async function TestWorkflowPage() {
  console.log("[TestPage] 1. Starting");
  
  const run = await start(testWorkflow, ["world"]);
  console.log("[TestPage] 2. Started, runId:", run.runId);
  
  const status = await run.status;
  console.log("[TestPage] 3. Status:", status);
  
  console.log("[TestPage] 4. Awaiting returnValue...");
  const result = await run.returnValue;  // <-- ❌ code will not move past this point, will ultimately timeout
  console.log("[TestPage] 5. Got result:", result);
  
  return (
    <div className="p-8">
      <h1>Test Workflow Result</h1>
      <pre>{JSON.stringify(result, null, 2)}</pre>
    </div>
  );
}

Logs

✅ work in development

[TestPage] 1. Starting
[TestPage] 2. Started, runId: wrun_01KCJA3HBQNQ5NP7E092NQXSP1
[TestPage] 3. Status: pending
[TestPage] 4. Awaiting returnValue...
[testWorkflow] 1. Started with: world
 POST /.well-known/workflow/v1/flow 503 in 66ms (compile: 3ms, render: 63ms)
[testWorkflow] 1. Started with: world
[testWorkflow] 2. After sleep
 POST /.well-known/workflow/v1/flow 200 in 30ms (compile: 2ms, render: 28ms)
[TestPage] 5. Got result: { message: 'Hello world', timestamp: 1765846142391 }
 GET / 200 in 3.1s (compile: 5ms, render: 3.1s)

❌ Fails in prod on vercel world

2025-12-16 00:50:41.201 [info] [TestPage] 1. Starting
2025-12-16 00:50:41.570 [info] [TestPage] 2. Started, runId: wrun_01KCJA6M2F8F2RSAXWYXZ3W754
2025-12-16 00:50:41.632 [info] [TestPage] 3. Status: pending
2025-12-16 00:50:41.632 [info] [TestPage] 4. Awaiting returnValue...
2025-12-16 00:50:41.903 [info] [testWorkflow] 1. Started with: world
2025-12-16 00:50:46.892 [info] [testWorkflow] 1. Started with: world
2025-12-16 00:50:46.894 [info] [testWorkflow] 2. After sleep
2025-12-16 00:55:40.884 [error] Vercel Runtime Timeout Error: Task timed out after 300 seconds

The workflow is marked as completed in the observability panel:

Image

Activity

  1. remiconnesson commented on Dec 16, 2025

    @remiconnesson
    Author

    I patched @workflow/world-vercel/dist/utils.js to log the results of the fetch util, suspecting that the result of the fetch call was being cached during the render of the RSC.

    We can see in the logs below that the reply always contain status: 'pending' despite the workflow being finished.

    Patch of @workflow/world-vercel/dist/utils.js

    diff --git a/node_modules/@workflow/world-vercel/dist/utils.js b/node_modules/@workflow/world-vercel/dist/utils.js
    index 5df338c..c48f772 100644
    --- a/node_modules/@workflow/world-vercel/dist/utils.js
    +++ b/node_modules/@workflow/world-vercel/dist/utils.js
    @@ -131,6 +131,7 @@ export async function makeRequest({ endpoint, options = {}, config = {}, schema,
         }
         try {
             const text = await response.text();
    +        console.log(text);
             return schema.parse(JSON.parse(text));
         }
         catch (error) {
    

    Logs from the workflow

    2025-12-16 12:39:28.809 [info] {"blobStorageBytes":52,"createdAt":"2025-12-16T12:39:23.442Z","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","executionContext":{"traceCarrier":{}},"lastStorageReportAt":"2025-12-16T12:39:23.939Z","ownerId":"team_aOsA<...offuscated...>","projectId":"prj_T4RV<...offuscated...>","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","startedAt":"2025-12-16T12:39:23.829Z","status":"running","streamStorageBytes":0,"updatedAt":"2025-12-16T12:39:23.939Z","workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","input":[[1],"world"]}
    2025-12-16 12:39:28.850 [info] {"data":[{"eventId":"evnt_01KCKJRA06CDJ7E9S0RE0JYY9C","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","createdAt":"2025-12-16T12:39:23.910Z","correlationId":"wait_01KCKJR9XNFNRB4E3S6CDC5T6G","eventType":"wait_created","eventData":{"resumeAt":"2025-12-16T12:39:25.895Z"}}],"cursor":null,"hasMore":false}
    2025-12-16 12:39:28.877 [info] {"runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","eventId":"evnt_01KCKJRETXMRZY2KW3Q5CRK194","correlationId":"wait_01KCKJR9XNFNRB4E3S6CDC5T6G","eventType":"wait_completed","createdAt":"2025-12-16T12:39:28.861Z"}
    2025-12-16 12:39:28.880 [info] [testWorkflow] 1. Started with: world
    2025-12-16 12:39:28.881 [info] [testWorkflow] 2. After sleep
    2025-12-16 12:39:28.975 [info] {"blobStorageBytes":109,"completedAt":"2025-12-16T12:39:28.929Z","createdAt":"2025-12-16T12:39:23.442Z","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","executionContext":{"traceCarrier":{}},"lastStorageReportAt":"2025-12-16T12:39:28.928Z","ownerId":"team_aOsA<...offuscated...>","projectId":"prj_T4RV<...offuscated...>","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","startedAt":"2025-12-16T12:39:23.829Z","status":"completed","streamStorageBytes":0,"updatedAt":"2025-12-16T12:39:28.929Z","workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","input":[[1],"world"],"output":[{"message":1,"timestamp":2},"Hello world",1765888768861]}
    

    Logs from the RSC

    2025-12-16 12:39:23.421 [info] [TestPage] 1. Starting
    2025-12-16 12:39:23.534 [info] {"runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","ownerId":"team_aOsA<...offuscated...>","projectId":"prj_T4RV<...offuscated...>","environment":"preview","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","status":"pending","workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","executionContext":{"traceCarrier":{}},"blobStorageBytes":13,"streamStorageBytes":0,"lastStorageReportAt":"2025-12-16T12:39:23.490Z","createdAt":"2025-12-16T12:39:23.442Z","updatedAt":"2025-12-16T12:39:23.490Z","input":[[1],"world"]}
    2025-12-16 12:39:23.615 [info] [TestPage] 2. Started, runId: wrun_01KCKJR9HJ2G53M4F75XYF75QC
    2025-12-16 12:39:23.655 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:23.655 [info] [TestPage] 3. Status: pending
    2025-12-16 12:39:23.655 [info] [TestPage] 4. Awaiting returnValue...
    2025-12-16 12:39:23.656 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:24.657 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:27.660 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:28.662 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:29.663 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:30.664 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:35.671 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:36.672 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    2025-12-16 12:39:37.673 [info] {"projectId":"prj_T4RV<...offuscated...>","status":"pending","ownerId":"team_aOsA<...offuscated...>","lastStorageReportAt":"2025-12-16T12:39:23.490Z","runId":"wrun_01KCKJR9HJ2G53M4F75XYF75QC","deploymentId":"dpl_Xk7a9G83hDkkW8PEmReQTDPHbUYG","environment":"preview","streamStorageBytes":0,"workflowName":"workflow//app/workflows/test-workflow.ts//testWorkflow","createdAt":"2025-12-16T12:39:23.442Z","executionContext":{"traceCarrier":{}},"updatedAt":"2025-12-16T12:39:23.490Z","blobStorageBytes":13,"input":[[1],"world"]}
    ...
    
  2. adriandlam commented on Dec 17, 2025

    @adriandlam
    Contributor

    hey @remiconnesson! thanks for the minimum repro, i believe it should be fixed in #639 but feel free to re-open if it isn't!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions