Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/convex/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineSchema({
parameters: v.any(),
taskCount: v.optional(v.number()),
endTime: v.optional(v.number()),
pool: v.optional(v.union(v.literal("new"), v.literal("old"))),
pool: v.optional(v.string()),
}),
tasks: defineTable({
runId: v.id("runs"),
Expand Down
2 changes: 1 addition & 1 deletion example/convex/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const modules = import.meta.glob("./**/*.*s");
// explicitly register it with its schema and modules.
export function initConvexTest() {
const t = convexTest(schema, modules);
t.registerComponent("workpool", workpool.schema, workpool.modules);
workpool.register(t);
return t;
}

Expand Down
17 changes: 7 additions & 10 deletions example/convex/test/scenarios/burstyBatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,15 @@ const parameters = {
* Tests the STATUS_COOLDOWN behavior and its effect on OCC conflicts.
*
* Each wave enqueues tasks individually via Promise.all, so every enqueue
* runs kickMainLoop concurrently. kickMainLoop reads the `runStatus`
* document and:
* - If "running": returns immediately (read-only, no conflict).
* - If "scheduled" or "idle": writes to `runStatus` to transition to
* "running" — concurrent writes cause OCC retries.
* runs kickMainLoop concurrently. batch-worker keeps loop lifecycle state in
* its own component tables and uses cooldown polling so bursts can be absorbed
* without every enqueue fighting to reschedule the loop.
*
* Without the cooldown, the loop transitions to scheduled/idle between
* waves, so the next wave's concurrent enqueues all race to write
* runStatus → OCC conflicts and retries.
* Without the cooldown, the loop transitions to idle between waves, so the
* next wave's concurrent enqueues all race to wake the worker.
*
* With the cooldown, runStatus stays "running" between waves, so
* kickMainLoop short-circuits on a read — no writes, no conflicts.
* With the cooldown, batch-worker stays in its running/cooling-down path
* between waves, so pings are cheap no-ops while work is picked up promptly.
*
* Run:
* npx convex run --push test/scenarios/burstyBatches:default '{}'
Expand Down
52 changes: 17 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"chokidar-cli": "3.0.0",
"convex": "1.41.0",
"convex-helpers": "0.1.111",
"convex-test": "0.0.51",
"convex-test": "0.0.53",
"eslint": "10.0.2",
"eslint-plugin-react-hooks": "7.1.0-canary-3f0b9e61-20260317",
"eslint-plugin-react-refresh": "0.5.0",
Expand All @@ -100,5 +100,8 @@
"vitest": "4.1.8"
},
"types": "./dist/client/index.d.ts",
"module": "./dist/client/index.js"
"module": "./dist/client/index.js",
"dependencies": {
"@convex-dev/batch-worker": "^0.2.0"
}
}
Loading
Loading