Skip to content

fix(copilot): fix copilot running workflow stuck on 10mb error#3999

Merged
TheodoreSpeaks merged 5 commits intostagingfrom
fix/run-workflow-body-exceeded
Apr 7, 2026
Merged

fix(copilot): fix copilot running workflow stuck on 10mb error#3999
TheodoreSpeaks merged 5 commits intostagingfrom
fix/run-workflow-body-exceeded

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

@TheodoreSpeaks TheodoreSpeaks commented Apr 6, 2026

Summary

Workflow executions failing with request payload too large will hang with "Running workflow" forever. This is because the reporting tool fails to run as well due to the 10mb constraint. On payload too large, attempt to strip logs and resend the completion.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Validated that 10mb limit failure is reported back to copilot.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 7, 2026 1:00am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 6, 2026

PR Summary

Low Risk
Low risk: small client-side error-handling change that only affects reporting tool completion, with a conditional retry when payloads exceed the Next.js body size limit.

Overview
Prevents Copilot workflow runs from hanging when /api/copilot/confirm fails due to Next.js truncating JSON bodies over ~10MB.

reportCompletion now measures the serialized payload size and, on a failed request with a large payload, retries the confirmation request with data.logs stripped out (and adds targeted warning logs for the initial failure and retry).

Reviewed by Cursor Bugbot for commit 8064090. Bugbot is set up for automated code reviews on this repo. Configure here.

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9c99c3a. Configure here.

@TheodoreSpeaks TheodoreSpeaks marked this pull request as ready for review April 7, 2026 00:28
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR fixes a UX hang in the Copilot run tool where a workflow execution failing due to a 10MB payload limit would cause the UI to get stuck in "Running workflow" forever. The root cause was that reportCompletion — the function that signals completion back to the server — was itself hitting the same body-size limit, silently failing and never unblocking the copilot state machine.

The fix pre-serializes the request body, checks its size on a non-OK response, and strips the logs field (the heaviest part of the payload) before retrying. This is a well-targeted and correct approach to the problem.

  • Fix approach: On a non-OK response, if the payload exceeds a size threshold, retry reportCompletion without logs — prevents the workflow from hanging silently.
  • Threshold concern: The retry guard uses a 1MB threshold (LARGE_PAYLOAD_THRESHOLD = 1024 * 1024) while the app's actual Next.js body limit is 10MB (per MAX_REQUEST_BODY_SIZE_BYTES in tools/index.ts). Any request failure where the body exceeds 1MB — for any reason, including auth errors, server errors, etc. — silently strips execution logs and retries, discarding potentially valuable debugging data even when the payload is far below the real 10MB ceiling. The threshold should be closer to the actual limit.
  • Minor inefficiency: new Blob([body]).size is evaluated twice (condition check + logger field) when it could be computed once.

Confidence Score: 4/5

Safe to merge; fix correctly resolves the reported hang, with a minor threshold calibration recommended.

Score of 4 reflects one P2 finding: the 1MB retry threshold is substantially below the actual 10MB server limit, meaning any failed request with a body over 1MB silently loses logs regardless of whether size was the cause. This doesn't break the fix but could hide debugging information in production. Straightforward to address by raising the threshold closer to the real limit.

apps/sim/lib/copilot/client-sse/run-tool-execution.ts — LARGE_PAYLOAD_THRESHOLD value (1MB vs actual 10MB server limit)

Important Files Changed

Filename Overview
apps/sim/lib/copilot/client-sse/run-tool-execution.ts Adds payload-too-large retry logic in reportCompletion; fix is correct but the 1MB retry threshold is much lower than the actual 10MB server limit, potentially stripping logs on unrelated failures

Sequence Diagram

sequenceDiagram
    participant Client as Client (run-tool-execution.ts)
    participant Server as /api/copilot/confirm
    participant Redis as Redis

    Client->>Server: POST body (logs included, ~10MB+)
    Server-->>Client: 500 non-OK (body too large)
    Client->>Client: !res.ok && bodySize > 1MB?
    alt body is large → strip logs
        Client->>Server: POST retry (logs stripped)
        Server->>Redis: Publish completion event
        Server-->>Client: 200 OK
        Note over Client: Copilot unblocked
    else retry also fails
        Client->>Client: logger.warn (error not propagated)
    end
Loading

Reviews (1): Last reviewed commit: "Strip only logs on payload too large" | Re-trigger Greptile

@TheodoreSpeaks TheodoreSpeaks merged commit df2c47a into staging Apr 7, 2026
12 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the fix/run-workflow-body-exceeded branch April 7, 2026 01:19
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.

1 participant