Skip to content

fix: propagate downstream failure status in webhook forwarding#227

Draft
bukinoshita wants to merge 1 commit intomainfrom
fix/propagate-forward-status-ab79
Draft

fix: propagate downstream failure status in webhook forwarding#227
bukinoshita wants to merge 1 commit 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.

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>
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.

2 participants