fix(webhook): return 202 with task_id on sync timeout, add polling endpoint#80
Open
kagura-agent wants to merge 1 commit intoghostwright:mainfrom
Open
fix(webhook): return 202 with task_id on sync timeout, add polling endpoint#80kagura-agent wants to merge 1 commit intoghostwright:mainfrom
kagura-agent wants to merge 1 commit intoghostwright:mainfrom
Conversation
…dpoint When sync mode times out, the response was previously lost (504 returned). Now returns 202 Accepted with a task_id, stores the response when the agent eventually completes, and exposes handlePollRequest() for GET /webhook/poll?task_id=xxx to retrieve it. Also fixes signature verification to exclude the signature field from HMAC computation (was impossible to verify correctly before). Closes ghostwright#26
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.
Problem
When a sync webhook request takes longer than
syncTimeoutMs(default 25s), the channel returns504and the agent's response is lost forever — even though the agent completes work moments later (issue #26).Solution
504, sync timeout now returns202 Acceptedwith atask_idhandlePollRequest()method forGET /webhook/poll?task_id=xxx:200with response when complete202while still processing404for unknown task IDs400for missing task_id parameterAlso fixes signature verification — HMAC was previously computed over the full body including the signature field, making verification impossible in practice. Now correctly excludes the
signaturefield before computing HMAC.Changes
src/channels/webhook.ts: Add async fallback + polling + fix signature verificationsrc/channels/__tests__/webhook.test.ts: 4 new tests (timeout→202, poll complete, poll pending, poll unknown, poll missing param)Testing
Closes #26