Skip to content

fix: propagate downstream failure status in webhook forwarding#227

Merged
felipefreitag merged 5 commits intomainfrom
fix/propagate-forward-status-ab79
Apr 14, 2026
Merged

fix: propagate downstream failure status in webhook forwarding#227
felipefreitag merged 5 commits intomainfrom
fix/propagate-forward-status-ab79

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary by cubic

Propagates downstream HTTP status when --forward-to is used so Resend retries on local handler failures. Addresses BU-649 by stopping the always-200 OK behavior.

  • Bug Fixes

    • Forward first, then log; use the result for CLI output and upstream response.
    • Propagate non-2xx from the target; 2xx maps to 200 OK upstream.
    • Map forwarding errors (connection refused, timeout) to 502 Bad Gateway.
    • Add 30s forwarding timeout with AbortSignal.timeout to prevent hangs.
  • Refactors

    • Extracted resolve-upstream.ts to map forward results to upstream responses.

Written for commit 4a4346b. Summary will update on new commits.

cursoragent and others added 2 commits April 9, 2026 17:30
When --forward-to is set, the listener now returns the downstream
HTTP status to Resend instead of always returning 200 OK. This
preserves Resend's retry behavior when the local handler fails.

- Non-2xx downstream responses are propagated as-is to the upstream
- Forwarding errors (connection refused, timeout) return 502
- Added AbortSignal.timeout(30s) to prevent stalled forwarding
- Extracted resolveUpstream to its own utility file

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
@bukinoshita
Copy link
Copy Markdown
Member Author

@cubic-dev-ai can you review?

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai bot commented Apr 13, 2026

@cubic-dev-ai can you review?

@bukinoshita I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/commands/webhooks/listen-forward.test.ts">

<violation number="1" location="tests/commands/webhooks/listen-forward.test.ts:79">
P2: This AbortController is never wired into the listener, so aborting it in teardown does nothing and the test leaks the background server.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread tests/commands/webhooks/listen-forward.test.ts Outdated
@bukinoshita bukinoshita marked this pull request as ready for review April 13, 2026 22:14
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

- Export ForwardResult type from resolve-upstream and reuse in listen.ts
- Detect AbortSignal timeout (DOMException/TimeoutError) and map to 504
- Wrap request handler in try/catch to prevent unhandled rejections from readBody
@felipefreitag felipefreitag merged commit 83b10b4 into main Apr 14, 2026
7 checks passed
@felipefreitag felipefreitag deleted the fix/propagate-forward-status-ab79 branch April 14, 2026 18:49
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.

3 participants