Repository navigation
Match Convex 1.50 scheduling and support future references and services - #203
Conversation
commit: |
There was a problem hiding this comment.
2 issues found across 8 files
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="index.ts">
<violation number="1" location="index.ts:2228">
P2: Cancellation does not propagate to tasks scheduled afterward, so a canceled action can still enqueue work that runs. Track the canceled request through nested scheduling and create those descendant jobs as canceled.</violation>
<violation number="2" location="index.ts:2228">
P2: An action that cancels its own scheduled job and then throws is recorded as `failed`, overwriting `canceled`. Preserve the canceled state when handling a post-cancellation action error.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| await getSyscalls().asyncSyscall("1.0/cancel_job", jsonArgs); | ||
| // Actions may cancel their own job; only mutation cancellation | ||
| // checks the scheduled request ID. | ||
| db.patch("_scheduled_functions", args.id, { |
There was a problem hiding this comment.
P2: Cancellation does not propagate to tasks scheduled afterward, so a canceled action can still enqueue work that runs. Track the canceled request through nested scheduling and create those descendant jobs as canceled.
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 index.ts, line 2228:
<comment>Cancellation does not propagate to tasks scheduled afterward, so a canceled action can still enqueue work that runs. Track the canceled request through nested scheduling and create those descendant jobs as canceled.</comment>
<file context>
@@ -2213,8 +2218,16 @@ function asyncSyscallImpl() {
- await getSyscalls().asyncSyscall("1.0/cancel_job", jsonArgs);
+ // Actions may cancel their own job; only mutation cancellation
+ // checks the scheduled request ID.
+ db.patch("_scheduled_functions", args.id, {
+ state: { kind: "canceled" },
+ });
</file context>
There was a problem hiding this comment.
I don't think the cloud behavior is that canceling an action retroactively cancels any of its scheduled work. but i think it does prevent future scheduling. we can just comment that here for now and fix in a follow-up PR though. that might be more involved
| await getSyscalls().asyncSyscall("1.0/cancel_job", jsonArgs); | ||
| // Actions may cancel their own job; only mutation cancellation | ||
| // checks the scheduled request ID. | ||
| db.patch("_scheduled_functions", args.id, { |
There was a problem hiding this comment.
P2: An action that cancels its own scheduled job and then throws is recorded as failed, overwriting canceled. Preserve the canceled state when handling a post-cancellation action error.
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 index.ts, line 2228:
<comment>An action that cancels its own scheduled job and then throws is recorded as `failed`, overwriting `canceled`. Preserve the canceled state when handling a post-cancellation action error.</comment>
<file context>
@@ -2213,8 +2218,16 @@ function asyncSyscallImpl() {
- await getSyscalls().asyncSyscall("1.0/cancel_job", jsonArgs);
+ // Actions may cancel their own job; only mutation cancellation
+ // checks the scheduled request ID.
+ db.patch("_scheduled_functions", args.id, {
+ state: { kind: "canceled" },
+ });
</file context>
There was a problem hiding this comment.
an action that cancels itself I don't think throws in the cloud version, so it'll just go to a canceled state?
Scheduled mutation self-cancellation currently commits writes, marks the job canceled, and then hits a scheduler invariant. Match the installed Convex version: 1.50+ throws
ScheduledFunctionCancelingItself, with rollback and a failed job when uncaught; older versions warn and ignore cancellation. A simple major/minor comparison includes future major versions. Direct cancellation from actions remains allowed; mutations use the inherited scheduled request ID, including mutations called by scheduled actions.Accept
FunctionReference_futureint.query,t.mutation, andt.action, using Convex's exported types,OptionalRestArgs, andFunctionReturnType. Raise the Convex peer floor from^1.43.0to^1.46.0, where these exports are available. The development dependency is 1.50.0.Add
1.0/createServiceTokenand1.0/getServiceUrlfor actions and HTTP actions. The AI gateway receives an unsigned five-minute test JWT andhttps://ai-gateway.convex.test; unsupported services and query/mutation calls fail. Adapt the JWT test fixture to 1.50's required claims property.v.function()remains with #182. Includes a patch changeset documenting the new peer floor.Remaining action-cancellation parity gaps are documented with a TODO and deferred: new tasks scheduled after cancellation should start canceled (including through nested calls), canceled actions should stay canceled if they later throw, and canceling terminal jobs should preserve their state.
Validation:
exactOptionalPropertyTypes, including future-reference argument/return inference; 33 focused runtime tests pass.git diff --checkpasses.