Repository navigation
feat(plugins): Retry failed plugin webhook writes with tasks - #4109
Merged
Merged
Conversation
Plugin routes and heartbeats get tasks.start({ name, key, payload }).
Core stores the payload in junior_plugin_tasks, one row per plugin and
key, sends a small signed message on junior_plugin_tasks, and runs the
plugin's task with a payload schema. A failed run is delivered again
after 30, 60, 120, and 240 seconds, and the fifth failed run ends the
task as failed. The heartbeat sends again a task whose lease expired.
The GitHub webhook starts an applyPullRequestOutcome task when the
inline pull request outcome write fails.
Closes #4104
Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 503a20e. Configure here.
Contributor
|
1 screenshot change — 1 changed · 0 added · 0 removed Review screenshots in Frameshift
|
…t-retry # Conflicts: # packages/junior/migrations/meta/0163_snapshot.json # packages/junior/migrations/meta/_journal.json
Drop the junior_plugin_tasks table, its migration, the row lease, and the heartbeat recovery. tasks.start now sends the JSON payload in the signed queue message, with an idempotency key that hashes the plugin, task name, and key, so a long key fits the queue's limit. A failed run retries after 30, 60, 120, then 240 seconds. The fifth failed delivery logs plugin.task.failed and is acknowledged. Co-Authored-By: BYK <[email protected]>
…t-retry Co-Authored-By: BYK <[email protected]> # Conflicts: # packages/junior/src/chat/plugins/task-queue.ts
BYK
approved these changes
Nov 24, 2026
BYK
added a commit
that referenced
this pull request
Nov 24, 2026
…fill (#4192) This repairs repository names that #4147's backfill left stale. GitHub migration 0020 from that PR added missing repositories to Junior's code index with `ON CONFLICT DO NOTHING`. When the index already had a repository under its name from before a rename, it kept that name, and 0021 then dropped the newer copy in the plugin table. The plugin finds pull requests by repository name for merge conflict checks, next-action sync, preview images, and Resume. For a renamed repository, those lookups miss until a lifecycle webhook records the new name. **Repair.** The GitHub plugin reads the current `full_name` of each repository in the code index from GitHub by its id, and records each name that changed. The requests use one metadata-only installation token and run four at a time. A 404 leaves the stored name as it is. Any other error is logged for that repository, and the repair moves on to the next. **Runs once.** The heartbeat starts the `repairRepositoryNames` task with a fixed key until a done mark is in plugin state. The task checks the mark, repairs the names, and sets the mark. This uses the started tasks from #4109, so the GitHub reads run outside the heartbeat, a failed run retries, and two heartbeats cannot start two repairs. After the mark is set, each heartbeat does one state read for it. **Plugin API.** `PluginCodeChanges.recordRepository({ name, providerId, updatedAt })` is a new write. It is the repository upsert that `record()` already runs, now a function of its own, so the same `updatedAt` guard applies and an older name cannot replace a newer one. The repair writes with the time of the run. To list the stored repositories, the repair reads all of the plugin's code changes with `codeChanges.list({})`, so it needs no new read. That is one query, run once. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A2e495f28ee4179158c8af1f4deeb197f --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A2e495f28ee4179158c8af1f4deeb197f) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A2e495f28ee4179158c8af1f4deeb197f/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
23 tasks done
This branch was successfully deployed
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.

GitHub sends a webhook only once. When the pull request outcome write failed inside the webhook, the outcome was lost until the daily reconcile reached that repository. This adds a retried path for plugin writes that fail inside a route, and uses it for the GitHub pull request outcome.
Plugin tasks that a plugin starts
ctx.tasks.start({ name, key, payload }).tasksthat has a Zodpayloadschema runs only when the plugin starts it. Tasks withoutpayloadstill run after each completed session, as before. Session scheduling skips tasks with a payload.tasks.startsends a signed{ plugin, name, payload }message on the existingjunior_plugin_taskstopic. The payload travels as JSON in the message. It is checked against the task's schema before the send and parsed again before each run. Core stores nothing.QueueRetryDirectivenow accepts{ afterSeconds }, which maps to the Vercel Queues retry handler. The fifth delivery that fails logsplugin.task.failedand is acknowledged.payload,state,annotations,codeChanges, andconversationChanges, like a plugin route. It has no session.GitHub pull request outcomes
The webhook still applies the outcome inline. When
applyGitHubPullRequestOutcomethrows, it logs a warning, starts anapplyPullRequestOutcometask with the outcome as payload and the keypull-request-outcome:<pull request id>:<state>:<updatedAt>, and returns 202. The task runsapplyGitHubPullRequestOutcomeagain. That path is safe to repeat: the outcome row updates withlte(updatedAt), the code index record and chip annotations upsert, and Inbox closes are no-ops for closed items.Scope choices
junior_plugin_taskstopic, so session tasks that fail now also wait before their next delivery instead of retrying at the visibility timeout.tasks.startcannot send the message, the error reaches the route. For GitHub, the daily reconcile still covers an outcome that never reached the queue.tasks.starthas no delay option yet.sendPluginTaskis now required where route and heartbeat contexts are built, so tests pass it explicitly.Docs:
extend/build-a-plugin.mddocumentstasks.start, the payload schema, the backoff, and the hashed key.TELEMETRY.mdlistsplugin.task.failed.Closes #4104
via @BYK.
--
View Session [Sentry]