Skip to content

feat(workflow): add webhook callback events - #348

Open
ianmacartney wants to merge 3 commits into
mainfrom
ian/webhook-callbacks
Open

ianmacartney wants to merge 3 commits into
mainfrom
ian/webhook-callbacks

Conversation

@ianmacartney

@ianmacartney ianmacartney commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Workflows can now create a callback URL for an external service and await its response as an event, instead of polling for completion. createWebhookEvent is available as both a standalone helper and a WorkflowManager method, returning the event ID, UUID, and full callback URL.

Behavior

  • Register GET, POST, PUT, PATCH, and DELETE callbacks in the workflow component. The UUID identifies the pending event and is excluded from callback logs. Completion checks and event delivery occur in one mutation, so concurrent callbacks and timeout races cannot deliver twice; losing deliveries return an already-processed success.
  • Include or discard request bodies and headers independently. Included fields over 256 KiB spill to component file storage and return storage IDs. Apps can resolve body/header download URLs with components.workflow.event.getWebhookPayloadUrl({ eventId, field }) via ctx.runQuery, after authorizing access in the app. DELETE request bodies are preserved.
  • Remove callback records and stored files when their events are cleaned up. Workflow cleanup also batches removal of callbacks never attached to a journal step. Losing deliveries discard their newly stored files.
  • Support optional timeouts on events and webhook events, failing pending events with Timeout.
  • Preserve the component HTTP mount path when constructing URLs, whether CONVEX_SITE_URL ends with a slash or not.
  • Add a Replicate image-generation example that creates a callback, starts a prediction, and awaits its result with a five-minute timeout. The example mounts workflow routes under /workflow/ and requires REPLICATE_API_TOKEN.

Release context

This branch was rebased onto current main. The recommendation is to proceed independently of waiting for component arguments: current Convex supports typed component configuration, and this implementation needs no additional installation arguments beyond the HTTP mount. Component routes must be explicitly exposed with httpPrefix; the component's system CONVEX_SITE_URL includes that mount path. See component HTTP routes and component configuration and HTTP actions.

Before publishing, verify the minimum Convex version needed for component HTTP routes and mounted site URLs against the package's existing ^1.46.0 peer range, and exercise a mounted callback on a live deployment. Local validation uses Convex 1.51.0; it does not establish compatibility with the oldest allowed peer version. The Replicate integration has not been exercised against the live service. The callback URL is a bearer capability; provider-specific signature verification is not included.

Validation

  • npm run build
  • npm test: 177 tests pass, including URL joining, DELETE payloads, credential-free logs, concurrent and sequential delivery, completion after timeout, stored-payload retrieval, and cleanup of awaited and unawaited callbacks across batches.
  • npm run typecheck
  • npm run lint: no errors; three existing query-filter warnings.
  • git diff --check

A follow-up fix commit addresses callback lifecycle, delivery races, credential logging, DELETE bodies, and stored-payload retrieval with regression coverage.

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/workflow@348

commit: 01029d0

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 11 files

This PR changes a public API contract. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Re-trigger cubic

Comment thread src/component/schema.ts Resolved
Comment thread src/component/http.ts Resolved
Comment thread src/component/http.ts Resolved
Comment thread src/component/http.ts Resolved
Comment thread src/component/http.ts Resolved

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 8 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/client/index.ts">

<violation number="1" location="src/client/index.ts:411">
P3: This paragraph is currently parsed as part of the `args.timeoutMs` parameter description. Start it with `@remarks` so payload retrieval and authorization guidance appears as general API documentation.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/client/index.ts
* `headersStorageId`) or `"discard"` (omit from the event value).
* @param args.timeoutMs - Optional timeout in milliseconds. If the webhook is
* not called within this duration, the event fails with error "Timeout".
* Large payloads can be read via

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This paragraph is currently parsed as part of the args.timeoutMs parameter description. Start it with @remarks so payload retrieval and authorization guidance appears as general API documentation.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/client/index.ts, line 411:

<comment>This paragraph is currently parsed as part of the `args.timeoutMs` parameter description. Start it with `@remarks` so payload retrieval and authorization guidance appears as general API documentation.</comment>

<file context>
@@ -408,6 +408,10 @@ export async function createEvent<Name extends string>(
  *   `headersStorageId`) or `"discard"` (omit from the event value).
  * @param args.timeoutMs - Optional timeout in milliseconds. If the webhook is
  *   not called within this duration, the event fails with error "Timeout".
+ * Large payloads can be read via
+ * `ctx.runQuery(component.event.getWebhookPayloadUrl, { eventId, field: "body" })`
+ * (or `field: "headers"`). Fetch the returned URL to read the stored bytes.
</file context>
Suggested change
* Large payloads can be read via
* @remarks

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