GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(server): scheduled tasks can run on a webhook by juliusmarminge · Pull Request #15085 · pingdotgg/t3code

feat(server): scheduled tasks can run on a webhook #15085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
juliusmarminge merged 14 commits into main from t3code/webhooks-server
Oct 5, 2026
+2,079 −53
Merged

feat(server): scheduled tasks can run on a webhook #15085

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
699ab02
feat(server): scheduled tasks can run on a webhook
juliusmarminge Oct 3, 2026
7f0a7a2
chore(server): keep webhook helpers module-private
juliusmarminge Oct 3, 2026
ce3c5a7
fix(web,mobile): label webhook tasks until their editors land
juliusmarminge Oct 3, 2026
fdfc501
fix(server): harden the webhook route against floods and races
juliusmarminge Oct 3, 2026
3dd09ab
test(server): drop an unused type directive
juliusmarminge Oct 3, 2026
595eb9e
fix(server): delivery log keeps the newest requests on timestamp ties
juliusmarminge Oct 3, 2026
f9cb655
fix(server): webhook delivery log stays private and bounded
juliusmarminge Oct 3, 2026
75e516b
fix(web): webhook tasks hide run-now and explain unopened deep links
juliusmarminge Oct 3, 2026
2c3ab46
fix(server): webhook saves and dispatch hold up under concurrency
juliusmarminge Oct 3, 2026
90fedc7
fix(web): thread automations panel disables run-now for webhook tasks
juliusmarminge Oct 3, 2026
c230d88
fix(server): rotation and the delivery cap respect recreated tasks
juliusmarminge Oct 3, 2026
d63ef44
fix(server): queue counts are per task generation
juliusmarminge Oct 3, 2026
c8cf017
refactor(server): the webhook route is part of the environment HttpApi
juliusmarminge Oct 3, 2026
08df570
fix(server): queued webhook deliveries skip tasks switched off the we…
juliusmarminge Oct 5, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
fix(server): rotation and the delivery cap respect recreated tasks
- Rotating a token matches the task's created_at, so it cannot land on a
  task deleted and recreated under the same id.
- Deleting a task clears its queued-delivery count.
- A request refused by the queue cap is not logged, so it cannot push real
  deliveries out of the log.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@juliusmarminge
juliusmarminge committed Oct 5, 2026
commit c230d881cd54b2524cec943f0d56f4ca9305a96a

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

36 changes: 23 additions & 13 deletions 36 apps/server/src/scheduledTasks/ScheduledTaskService.ts
Show comments
View file
Open in desktop
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,12 @@ export const layer = Layer.effect(
next.delete(input.id);
return next;
}),
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

// Old deliveries still finishing must not fill a recreated task's queue.
Ref.update(webhookQueued, (queued) => {
const next = new Map(queued);
next.delete(input.id);
return next;
}),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

]),
),
Effect.andThen(notifyChanged),
Expand Down Expand Up @@ -1093,15 +1099,21 @@ export const layer = Layer.effect(
}
const token = yield* newWebhookToken;
const now = yield* localNow;
yield* sql`
// Matching created_at keeps a rotation from landing on a task deleted
// and recreated under the same id since it was loaded.
const updated = yield* sql<{ task_id: string }>`
UPDATE scheduled_tasks
SET webhook_token = ${token}, updated_at = ${iso(now)}
WHERE task_id = ${input.id}
WHERE task_id = ${input.id} AND created_at = ${task.createdAt}
RETURNING task_id
`.pipe(
Effect.mapError((cause) =>
taskError("Could not rotate webhook token.", { taskId: input.id, cause }),
),
);
if (updated.length === 0) {
return yield* taskError("Schedule task was deleted or replaced.", { taskId: input.id });
}
yield* notifyChanged;
return { task: yield* loadTask(input.id) };
});
Expand Down Expand Up @@ -1342,30 +1354,28 @@ export const layer = Layer.effect(
}

const rendered = renderWebhookPrompt(task.prompt, request);
yield* log("accepted", {
signatureVerified: signature !== null,
missing: rendered.missing,
renderedPrompt: rendered.prompt,
});
// Bound the deliveries waiting behind a slow run, so steady traffic to
// a stuck task cannot pile up parked fibers.
// Bound the deliveries one task holds, so steady traffic to a stuck
// task cannot pile up parked fibers. A refused request is not logged,
// so it cannot push real deliveries out of the log.
const queued = yield* Ref.modify(webhookQueued, (counts) => {
const count = counts.get(task.id) ?? 0;
return count >= WEBHOOK_MAX_QUEUED_PER_TASK
? ([false, counts] as const)
: ([true, new Map(counts).set(task.id, count + 1)] as const);
});
if (!queued) {
yield* markDeliveryFailed(deliveryId, "Too many deliveries are waiting for this task.");
return { _tag: "rate_limited" as const };
}
if (!queued) return { _tag: "rate_limited" as const };
const release = Ref.update(webhookQueued, (counts) => {
const next = new Map(counts);
const count = (next.get(task.id) ?? 1) - 1;
if (count <= 0) next.delete(task.id);
else next.set(task.id, count);
return next;
});
yield* log("accepted", {
signatureVerified: signature !== null,
missing: rendered.missing,
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

renderedPrompt: rendered.prompt,
}).pipe(Effect.onError(() => release));
const permit = yield* webhookPermit(task.id);
yield* runTask(task, "webhook", { deliveryId, prompt: rendered.prompt }).pipe(
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Effect.flatMap((completed) =>
Expand Down
4 changes: 4 additions & 0 deletions 4 apps/server/src/scheduledTasks/ScheduledTaskService.webhook.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Queue from "effect/Queue";
import * as Schema from "effect/Schema";
import * as TestClock from "effect/testing/TestClock";

import * as ThreadLaunchService from "../orchestration-v2/ThreadLaunchService.ts";
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
Expand Down Expand Up @@ -402,6 +403,9 @@ it.effect("caps deliveries waiting behind a stuck run", () =>
);
assert.equal(waiting.filter((result) => result._tag === "accepted").length, 19);
assert.equal(waiting.at(-1)?._tag, "rate_limited");
// The refused request is not logged.
const logged = (yield* service.listWebhookDeliveries({ id: task.id })).deliveries;
assert.equal(logged.length, 20);
yield* Deferred.succeed(gate, undefined);
}),
{ gate },
Expand Down
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.