fix(orb): ack the GitHub webhook before the relay forward (#1623) - #1624
Merged
Conversation
handleOrbWebhook awaited forwardOrbEvent before returning the 202 it owes GitHub. In push mode that forward POSTs to the brokered self-host's relay URL with a 10s timeout; a slow path (e.g. a Tailscale-Funnel container) delays the response past GitHub's ~10s delivery deadline, so GitHub marks the delivery FAILED even though the Orb received + queued the event (rows still recorded status='received'). Extract the forward + its failure-persistence (for the retry-orb-relay cron) into a self-contained, fail-safe relayForward helper, and run it AFTER the response via executionCtx.waitUntil (fire-and-forget fallback where no execution context exists). No event is lost; the GitHub ACK is decoupled from downstream container latency.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1624 +/- ##
==========================================
+ Coverage 95.51% 95.52% +0.01%
==========================================
Files 204 204
Lines 22051 22056 +5
Branches 7966 7967 +1
==========================================
+ Hits 21062 21069 +7
+ Misses 413 412 -1
+ Partials 576 575 -1
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The central Orb App (
gittensory-api) was returning GitHub webhook delivery errors (visible in the App's Recent Deliveries) on bursty events likecheck_suite/check_run, even though every event was recordedstatus:"received"inorb_webhook_events. Root cause:handleOrbWebhookawaitedforwardOrbEventbefore sending the 202 it owes GitHub. In push mode that forward POSTs to the brokered self-host's relay URL with a 10s timeout; a slow path (e.g. a tailnet/Tailscale-Funnel container) delays the response past GitHub's ~10s delivery deadline, so GitHub marks the delivery failed — despite the Orb having received + queued the event.Fix: ACK GitHub immediately and run the relay forward after the response via
executionCtx.waitUntil(with a fire-and-forget fallback where no execution context exists). The forward + its failure-persistence for the retry-orb-relay cron are extracted into a self-contained, fail-saferelayForwardhelper.orb_relay_failuresfor the retry cron, and the self-host pull-sweep remains a backstop.Closes #1623.
Scope
site//CNAME/Pages; followsCONTRIBUTING.md.Validation
git diff --check·npm run actionlint·npm run typechecknpm run test:coverage—relayForwardcovered both arms (failed→persistorb_relay_failures; skipped→no-op, never throws) + the handler defers viawaitUntil(202 returned, forward scheduled not awaited).scheduleAfterResponseboth branches covered (waitUntil present in the new test; absent in the existing handler tests → fire-and-forget).npm run test:workers·build:mcp·test:mcp-pack·ui:*·npm audit --audit-level=moderateIf any required check was skipped, explain why:
Safety
Notes
gittensory-api(the central Orb receiver), which deploys via Cloudflare Workers Builds on merge. The self-host engine runshandleOrbRelay(the receiver), not this path, so no self-host rebuild is needed.registerOrbRelayTargetcurrently defaults to push. waitUntil fixes the GitHub-timeout regardless of mode; pull-mode is a robustness improvement to evaluate next.