gemi 0.125.0 → 0.126.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +2 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/auth/connections/ConnectionsController.d.ts.map +1 -1
- package/dist/auth/oauth/GoogleOAuthProvider.d.ts +1 -1
- package/dist/auth/oauth/GoogleOAuthProvider.d.ts.map +1 -1
- package/dist/auth/oauth/InstagramOAuthProvider.d.ts +1 -1
- package/dist/auth/oauth/InstagramOAuthProvider.d.ts.map +1 -1
- package/dist/auth/oauth/XOAuthProvider.d.ts.map +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-hff9w6rt.js → chunk-094m8mj3.js} +2 -2
- package/dist/{chunk-hff9w6rt.js.map → chunk-094m8mj3.js.map} +1 -1
- package/dist/chunk-0arss2xy.js +5 -0
- package/dist/{chunk-rany5zgk.js.map → chunk-0arss2xy.js.map} +5 -4
- package/dist/{chunk-mmqnq1qh.js → chunk-0f0xxqhy.js} +3 -3
- package/dist/{chunk-mmqnq1qh.js.map → chunk-0f0xxqhy.js.map} +1 -1
- package/dist/chunk-15bmfr7f.js +5 -0
- package/dist/{chunk-tabsxzg9.js.map → chunk-15bmfr7f.js.map} +5 -4
- package/dist/{chunk-910p6ne6.js → chunk-1dzs05dc.js} +2 -2
- package/dist/{chunk-910p6ne6.js.map → chunk-1dzs05dc.js.map} +1 -1
- package/dist/{chunk-rmgkc3a2.js → chunk-1eb4p352.js} +2 -2
- package/dist/{chunk-rmgkc3a2.js.map → chunk-1eb4p352.js.map} +1 -1
- package/dist/{chunk-cwt8e782.js → chunk-1gd1ykgj.js} +3 -3
- package/dist/{chunk-cwt8e782.js.map → chunk-1gd1ykgj.js.map} +1 -1
- package/dist/{chunk-stn0a56e.js → chunk-1v368y9a.js} +2 -2
- package/dist/{chunk-stn0a56e.js.map → chunk-1v368y9a.js.map} +1 -1
- package/dist/{chunk-x2j84d06.js → chunk-28bby5pp.js} +2 -2
- package/dist/{chunk-x2j84d06.js.map → chunk-28bby5pp.js.map} +1 -1
- package/dist/{chunk-gp00enrk.js → chunk-3fyhd641.js} +1 -1
- package/dist/{chunk-ex41d03h.js → chunk-43faxwf5.js} +2 -2
- package/dist/{chunk-ex41d03h.js.map → chunk-43faxwf5.js.map} +1 -1
- package/dist/{chunk-ey1xrbaz.js → chunk-56ryda9y.js} +2 -2
- package/dist/{chunk-ey1xrbaz.js.map → chunk-56ryda9y.js.map} +1 -1
- package/dist/{chunk-t2t63wa0.js → chunk-5vvfcdpk.js} +2 -2
- package/dist/{chunk-t2t63wa0.js.map → chunk-5vvfcdpk.js.map} +1 -1
- package/dist/{chunk-p5df4pn7.js → chunk-62zn06wb.js} +2 -2
- package/dist/{chunk-p5df4pn7.js.map → chunk-62zn06wb.js.map} +1 -1
- package/dist/{chunk-3br5zr7a.js → chunk-7dzprr9b.js} +3 -3
- package/dist/{chunk-3br5zr7a.js.map → chunk-7dzprr9b.js.map} +1 -1
- package/dist/{chunk-erzfs4t2.js → chunk-7eerqsg2.js} +2 -2
- package/dist/{chunk-erzfs4t2.js.map → chunk-7eerqsg2.js.map} +1 -1
- package/dist/{chunk-z5nfve1k.js → chunk-7nfprr9v.js} +2 -2
- package/dist/{chunk-z5nfve1k.js.map → chunk-7nfprr9v.js.map} +1 -1
- package/dist/{chunk-1jcngq6w.js → chunk-7x2n788t.js} +3 -3
- package/dist/{chunk-1jcngq6w.js.map → chunk-7x2n788t.js.map} +1 -1
- package/dist/{chunk-rwmja4zs.js → chunk-84rbdyhe.js} +2 -2
- package/dist/{chunk-rwmja4zs.js.map → chunk-84rbdyhe.js.map} +1 -1
- package/dist/chunk-87bmhng2.js +5 -0
- package/dist/{chunk-1xmh61fg.js.map → chunk-87bmhng2.js.map} +1 -1
- package/dist/{chunk-c0qpv8x7.js → chunk-87jj7n9q.js} +2 -2
- package/dist/{chunk-c0qpv8x7.js.map → chunk-87jj7n9q.js.map} +1 -1
- package/dist/{chunk-hxn0s3zh.js → chunk-89swy5aq.js} +2 -2
- package/dist/{chunk-hxn0s3zh.js.map → chunk-89swy5aq.js.map} +1 -1
- package/dist/{chunk-y9f2see3.js → chunk-8df7fn7f.js} +3 -3
- package/dist/{chunk-y9f2see3.js.map → chunk-8df7fn7f.js.map} +1 -1
- package/dist/{chunk-bny9s44t.js → chunk-99z9d0sa.js} +2 -2
- package/dist/{chunk-bny9s44t.js.map → chunk-99z9d0sa.js.map} +1 -1
- package/dist/{chunk-by5gwr8x.js → chunk-9hhxy88x.js} +2 -2
- package/dist/{chunk-by5gwr8x.js.map → chunk-9hhxy88x.js.map} +1 -1
- package/dist/{chunk-yhht1j7f.js → chunk-9x0pgkns.js} +2 -2
- package/dist/{chunk-yhht1j7f.js.map → chunk-9x0pgkns.js.map} +1 -1
- package/dist/{chunk-dy58aztm.js → chunk-avfntxm1.js} +2 -2
- package/dist/{chunk-dy58aztm.js.map → chunk-avfntxm1.js.map} +1 -1
- package/dist/{chunk-h8w9mzjj.js → chunk-b2pdqxj3.js} +11 -11
- package/dist/{chunk-h8w9mzjj.js.map → chunk-b2pdqxj3.js.map} +3 -4
- package/dist/{chunk-j12hpdxk.js → chunk-bghxdjqv.js} +1 -1
- package/dist/{chunk-6vz75swk.js → chunk-bhbxhk9e.js} +2 -2
- package/dist/{chunk-6vz75swk.js.map → chunk-bhbxhk9e.js.map} +1 -1
- package/dist/{chunk-6q6bhkyf.js → chunk-c48gag78.js} +1 -1
- package/dist/{chunk-5fh4pvyt.js → chunk-c65rh4k8.js} +2 -2
- package/dist/{chunk-5fh4pvyt.js.map → chunk-c65rh4k8.js.map} +1 -1
- package/dist/chunk-cwpezdpw.js +57 -0
- package/dist/{chunk-eyptwf54.js.map → chunk-cwpezdpw.js.map} +10 -5
- package/dist/{chunk-6wgh7nk6.js → chunk-dm7mada7.js} +3 -3
- package/dist/{chunk-6wgh7nk6.js.map → chunk-dm7mada7.js.map} +1 -1
- package/dist/{chunk-1mxb44n9.js → chunk-ebdkmzm9.js} +2 -2
- package/dist/{chunk-1mxb44n9.js.map → chunk-ebdkmzm9.js.map} +1 -1
- package/dist/{chunk-xfvegbxn.js → chunk-ecb8qggy.js} +2 -2
- package/dist/{chunk-xfvegbxn.js.map → chunk-ecb8qggy.js.map} +1 -1
- package/dist/{chunk-p6jbmcrg.js → chunk-etf6h5m1.js} +2 -2
- package/dist/{chunk-p6jbmcrg.js.map → chunk-etf6h5m1.js.map} +1 -1
- package/dist/{chunk-zq5375wd.js → chunk-ewv1m1sv.js} +3 -3
- package/dist/{chunk-zq5375wd.js.map → chunk-ewv1m1sv.js.map} +1 -1
- package/dist/{chunk-dxyxd7b3.js → chunk-gv59djt3.js} +2 -2
- package/dist/{chunk-dxyxd7b3.js.map → chunk-gv59djt3.js.map} +1 -1
- package/dist/{chunk-8tvfmy1a.js → chunk-gxp48t81.js} +4 -4
- package/dist/{chunk-8tvfmy1a.js.map → chunk-gxp48t81.js.map} +1 -1
- package/dist/{chunk-r923001x.js → chunk-h4755p9h.js} +2 -2
- package/dist/{chunk-r923001x.js.map → chunk-h4755p9h.js.map} +1 -1
- package/dist/{chunk-q6ah4yjg.js → chunk-hye22tpt.js} +2 -2
- package/dist/{chunk-q6ah4yjg.js.map → chunk-hye22tpt.js.map} +1 -1
- package/dist/{chunk-eq5svwca.js → chunk-jg3kg55f.js} +2 -2
- package/dist/{chunk-eq5svwca.js.map → chunk-jg3kg55f.js.map} +1 -1
- package/dist/{chunk-s4semb89.js → chunk-k6gvbvyw.js} +1 -1
- package/dist/{chunk-vhvvjaj3.js → chunk-kzk5r6v4.js} +3 -3
- package/dist/{chunk-vhvvjaj3.js.map → chunk-kzk5r6v4.js.map} +1 -1
- package/dist/{chunk-ghcvztxn.js → chunk-m63v6aze.js} +2 -2
- package/dist/{chunk-ghcvztxn.js.map → chunk-m63v6aze.js.map} +1 -1
- package/dist/{chunk-khdkrfxp.js → chunk-mj4n5mar.js} +2 -2
- package/dist/{chunk-khdkrfxp.js.map → chunk-mj4n5mar.js.map} +1 -1
- package/dist/{chunk-kcsa57km.js → chunk-mj7h1dgh.js} +2 -2
- package/dist/{chunk-kcsa57km.js.map → chunk-mj7h1dgh.js.map} +1 -1
- package/dist/{chunk-cpem1j1x.js → chunk-mpt5jg4e.js} +2 -2
- package/dist/{chunk-cpem1j1x.js.map → chunk-mpt5jg4e.js.map} +1 -1
- package/dist/{chunk-3kxe9geg.js → chunk-n8mxsfc2.js} +3 -3
- package/dist/{chunk-3kxe9geg.js.map → chunk-n8mxsfc2.js.map} +1 -1
- package/dist/{chunk-n3z83qhq.js → chunk-nrf23yan.js} +2 -2
- package/dist/{chunk-n3z83qhq.js.map → chunk-nrf23yan.js.map} +1 -1
- package/dist/{chunk-sv125fqq.js → chunk-nv2t87c3.js} +2 -2
- package/dist/{chunk-sv125fqq.js.map → chunk-nv2t87c3.js.map} +1 -1
- package/dist/{chunk-j10a0m7q.js → chunk-p0ccxfkq.js} +1 -1
- package/dist/{chunk-crnfxn9n.js → chunk-p7abyc0b.js} +2 -2
- package/dist/{chunk-crnfxn9n.js.map → chunk-p7abyc0b.js.map} +1 -1
- package/dist/{chunk-hzen9gh4.js → chunk-psdyfaf1.js} +2 -2
- package/dist/{chunk-hzen9gh4.js.map → chunk-psdyfaf1.js.map} +1 -1
- package/dist/{chunk-knq4ack4.js → chunk-q9mxjh10.js} +2 -2
- package/dist/{chunk-knq4ack4.js.map → chunk-q9mxjh10.js.map} +1 -1
- package/dist/{chunk-7zj6bk9a.js → chunk-qmcjh6de.js} +2 -2
- package/dist/{chunk-7zj6bk9a.js.map → chunk-qmcjh6de.js.map} +1 -1
- package/dist/{chunk-k1ebt28j.js → chunk-qy3s6pwz.js} +2 -2
- package/dist/{chunk-k1ebt28j.js.map → chunk-qy3s6pwz.js.map} +1 -1
- package/dist/{chunk-j5rwv09s.js → chunk-ravssmdy.js} +2 -2
- package/dist/{chunk-j5rwv09s.js.map → chunk-ravssmdy.js.map} +1 -1
- package/dist/{chunk-rvspb96n.js → chunk-rtb64x14.js} +3 -3
- package/dist/{chunk-rvspb96n.js.map → chunk-rtb64x14.js.map} +1 -1
- package/dist/{chunk-ayfjjgv2.js → chunk-rvdsaqdv.js} +1 -1
- package/dist/{chunk-7vrrgxwm.js → chunk-s0kns9q1.js} +3 -3
- package/dist/{chunk-7vrrgxwm.js.map → chunk-s0kns9q1.js.map} +1 -1
- package/dist/{chunk-entpqjyn.js → chunk-s2krqtwj.js} +2 -2
- package/dist/{chunk-entpqjyn.js.map → chunk-s2krqtwj.js.map} +1 -1
- package/dist/{chunk-xe2pm36q.js → chunk-s2y2b8tz.js} +2 -2
- package/dist/{chunk-xe2pm36q.js.map → chunk-s2y2b8tz.js.map} +1 -1
- package/dist/{chunk-t6qpm2j7.js → chunk-t8kzaxaa.js} +2 -2
- package/dist/{chunk-t6qpm2j7.js.map → chunk-t8kzaxaa.js.map} +1 -1
- package/dist/{chunk-0x1s02r1.js → chunk-v1eeh7a7.js} +3 -3
- package/dist/{chunk-0x1s02r1.js.map → chunk-v1eeh7a7.js.map} +1 -1
- package/dist/{chunk-npbf06c1.js → chunk-v7nw1g2n.js} +2 -2
- package/dist/{chunk-npbf06c1.js.map → chunk-v7nw1g2n.js.map} +1 -1
- package/dist/{chunk-b7a22evs.js → chunk-v80890xx.js} +3 -3
- package/dist/{chunk-b7a22evs.js.map → chunk-v80890xx.js.map} +1 -1
- package/dist/{chunk-p7mvp5nf.js → chunk-w4111j5d.js} +2 -2
- package/dist/{chunk-p7mvp5nf.js.map → chunk-w4111j5d.js.map} +1 -1
- package/dist/{chunk-m7pghdcy.js → chunk-wat33wxh.js} +2 -2
- package/dist/{chunk-m7pghdcy.js.map → chunk-wat33wxh.js.map} +1 -1
- package/dist/{chunk-1n40bdxf.js → chunk-x5vpjzpp.js} +2 -2
- package/dist/{chunk-1n40bdxf.js.map → chunk-x5vpjzpp.js.map} +1 -1
- package/dist/{chunk-g52fcwca.js → chunk-xe2cfmyb.js} +2 -2
- package/dist/{chunk-g52fcwca.js.map → chunk-xe2cfmyb.js.map} +1 -1
- package/dist/{chunk-jykkqwcy.js → chunk-ych1dv5q.js} +3 -3
- package/dist/{chunk-jykkqwcy.js.map → chunk-ych1dv5q.js.map} +1 -1
- package/dist/{chunk-ap3g6rbw.js → chunk-yffm8nxa.js} +2 -2
- package/dist/{chunk-ap3g6rbw.js.map → chunk-yffm8nxa.js.map} +1 -1
- package/dist/{chunk-6gwxvmjv.js → chunk-yg8se4vs.js} +3 -3
- package/dist/{chunk-6gwxvmjv.js.map → chunk-yg8se4vs.js.map} +1 -1
- package/dist/chunk-zbvdkh6q.js +10 -0
- package/dist/{chunk-b4x1dt3s.js.map → chunk-zbvdkh6q.js.map} +4 -3
- package/dist/{chunk-s4xg69r9.js → chunk-zy5gxk1g.js} +2 -2
- package/dist/{chunk-s4xg69r9.js.map → chunk-zy5gxk1g.js.map} +1 -1
- package/dist/client/index.js +46 -21
- package/dist/client/index.js.map +1 -1
- package/dist/client/useQuery.d.ts +9 -0
- package/dist/client/useQuery.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/Cache.d.ts +36 -0
- package/dist/facades/Cache.d.ts.map +1 -0
- package/dist/facades/Url.d.ts +12 -1
- package/dist/facades/Url.d.ts.map +1 -1
- package/dist/facades/index.d.ts +1 -0
- package/dist/facades/index.d.ts.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/Metadata.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/kernel/index.js +3 -3
- package/dist/kernel/index.js.map +3 -3
- package/dist/kernel/providers.d.ts +2 -2
- package/dist/kernel/providers.d.ts.map +1 -1
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/cache/CacheManager.d.ts +115 -0
- package/dist/services/cache/CacheManager.d.ts.map +1 -0
- package/dist/services/cache/CacheServiceProvider.d.ts +5 -0
- package/dist/services/cache/CacheServiceProvider.d.ts.map +1 -0
- package/dist/services/cache/CacheStore.d.ts +26 -0
- package/dist/services/cache/CacheStore.d.ts.map +1 -0
- package/dist/services/cache/MemoryCacheStore.d.ts +36 -0
- package/dist/services/cache/MemoryCacheStore.d.ts.map +1 -0
- package/dist/services/cache/RedisCacheStore.d.ts +54 -0
- package/dist/services/cache/RedisCacheStore.d.ts.map +1 -0
- package/dist/services/cache/config.d.ts +35 -0
- package/dist/services/cache/config.d.ts.map +1 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +9 -9
- package/dist/services/index.js.map +5 -5
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/stats/route-table.js +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/utils/appOrigin.d.ts +19 -0
- package/dist/utils/appOrigin.d.ts.map +1 -0
- package/dist/vitest/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-1xmh61fg.js +0 -5
- package/dist/chunk-b4x1dt3s.js +0 -10
- package/dist/chunk-eyptwf54.js +0 -57
- package/dist/chunk-rany5zgk.js +0 -5
- package/dist/chunk-tabsxzg9.js +0 -5
- /package/dist/{chunk-gp00enrk.js.map → chunk-3fyhd641.js.map} +0 -0
- /package/dist/{chunk-j12hpdxk.js.map → chunk-bghxdjqv.js.map} +0 -0
- /package/dist/{chunk-6q6bhkyf.js.map → chunk-c48gag78.js.map} +0 -0
- /package/dist/{chunk-s4semb89.js.map → chunk-k6gvbvyw.js.map} +0 -0
- /package/dist/{chunk-j10a0m7q.js.map → chunk-p0ccxfkq.js.map} +0 -0
- /package/dist/{chunk-ayfjjgv2.js.map → chunk-rvdsaqdv.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../services/lock/DatabaseLockStore.ts", "../services/lock/MemoryLockStore.ts", "../services/queue/workflow/WorkflowStore.ts", "../services/queue/workflow/DatabaseWorkflowStore.ts", "../services/queue/batch.ts", "../services/queue/DatabaseQueueDriver.ts", "../services/queue/config.ts", "../services/queue/workflow/MemoryWorkflowStore.ts", "../services/queue/MemoryQueueDriver.ts", "../services/queue/backoff.ts", "../services/queue/workflow/
|
|
3
|
+
"sources": ["../services/lock/DatabaseLockStore.ts", "../services/lock/MemoryLockStore.ts", "../services/queue/workflow/WorkflowStore.ts", "../services/queue/workflow/DatabaseWorkflowStore.ts", "../services/queue/batch.ts", "../services/queue/DatabaseQueueDriver.ts", "../services/queue/config.ts", "../services/queue/workflow/MemoryWorkflowStore.ts", "../services/queue/MemoryQueueDriver.ts", "../services/queue/backoff.ts", "../services/queue/workflow/Step.ts", "../services/queue/QueueManager.ts", "../services/queue/Job.ts", "../services/queue/workflow/WorkflowRuntime.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { SQL } from \"bun\";\n\nimport type { DatabaseConnection } from \"../../database/Connection\";\nimport type { Dialect } from \"../../database/dialect\";\nimport { runOnConnection, withTransaction } from \"../../orm/context\";\nimport { LockLostError, type LockStore } from \"./LockStore\";\n\nexport type DatabaseLockStoreOptions = {\n /**\n * The locks table. Default `gemi_locks`. A plain identifier, because it is\n * spliced into every statement.\n */\n table?: string;\n /**\n * SQLite only: the busy timeout given to a connection still at SQLite's `0`,\n * as `DatabaseQueueDriver` does. Default `1000`; `0` leaves the connection\n * alone.\n */\n busyTimeout?: number;\n};\n\n/**\n * Locks in a table of the application's database, so every process sharing\n * the database sees the same holder. One row per lock name, kept after\n * release so the name's fencing token keeps growing.\n *\n * Every statement is a single atomic row update, guarded by the holder's\n * owner, token and lease: `acquire` is \"take the row if its lease ran out\",\n * `extend` and `release` are \"change the row if it is still mine\". Leases are\n * measured on the database's clock, as the queue's are, so skewed replicas\n * agree on when one ran out. No Redis is involved.\n *\n * `fence` opens a transaction that locks the row first (`SELECT … FOR UPDATE`\n * on Postgres and MySQL, a write on SQLite, which takes the file's write\n * lock), so a new holder's `acquire` waits until the fenced work commits.\n *\n * Written for SQLite, Postgres and MySQL 8 / MariaDB 10.6+, like the queue's\n * driver.\n */\nexport class DatabaseLockStore implements LockStore {\n readonly table: string;\n private readonly sql: SQL;\n private readonly dialect: Dialect;\n private readonly connection: string | undefined;\n private readonly busyTimeout: number;\n private configured: Promise<void> | undefined;\n\n constructor(\n connection: Pick<DatabaseConnection, \"sql\" | \"dialect\"> &\n Partial<Pick<DatabaseConnection, \"name\">>,\n options: DatabaseLockStoreOptions = {},\n ) {\n const table = options.table ?? \"gemi_locks\";\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(table)) {\n throw new Error(\n `The lock table name \"${table}\" is not a plain identifier. Use ` +\n `letters, digits and underscores.`,\n );\n }\n this.table = table;\n this.sql = connection.sql;\n this.dialect = connection.dialect;\n this.connection = connection.name;\n this.busyTimeout = options.busyTimeout ?? 1000;\n }\n\n /** Creates the table if it does not exist; the DDL Prisma makes for the model in the docs. */\n async createTable(): Promise<void> {\n await this.configure();\n for (const statement of createLockTableStatements(this.dialect, this.table)) {\n await this.sql.unsafe(statement);\n }\n }\n\n async acquire(name: string, owner: string, ttlMs: number): Promise<number | null> {\n await this.configure();\n const q = this.sql;\n const now = this.now(q);\n await this.seed(q, name);\n\n if (this.mysql) {\n const result = await q`\n UPDATE ${this.name(q)}\n SET owner = ${owner}, token = token + 1, expires_at = ${now} + ${this.ms(q, ttlMs)},\n updated_at = ${now}\n WHERE name = ${name} AND expires_at <= ${now}\n `;\n if (affected(result) === 0) return null;\n // The owner is unique to this acquisition, so this reads our own row\n // unless the lease already ran out and was taken again.\n const [row] = (await q`\n SELECT token FROM ${this.name(q)} WHERE name = ${name} AND owner = ${owner}\n `) as Array<{ token: unknown }>;\n return row ? Number(row.token) : null;\n }\n\n const rows = (await q`\n UPDATE ${this.name(q)}\n SET owner = ${owner}, token = token + 1, expires_at = ${now} + ${this.ms(q, ttlMs)},\n updated_at = ${now}\n WHERE name = ${name} AND expires_at <= ${now}\n RETURNING token\n `) as Array<{ token: unknown }>;\n return rows[0] ? Number(rows[0].token) : null;\n }\n\n async extend(name: string, owner: string, token: number, ttlMs: number): Promise<boolean> {\n await this.configure();\n const q = this.sql;\n const now = this.now(q);\n const result = await q`\n UPDATE ${this.name(q)}\n SET expires_at = ${now} + ${this.ms(q, ttlMs)}, updated_at = ${now}\n WHERE name = ${name} AND owner = ${owner} AND token = ${token} AND expires_at > ${now}\n `;\n if (affected(result) > 0) return true;\n // MySQL counts changed rows, not matched ones, so a renewal that lands in\n // the same millisecond as the last one reports nothing changed.\n return this.mysql ? this.held(name, owner, token) : false;\n }\n\n async release(name: string, owner: string, token?: number): Promise<boolean> {\n await this.configure();\n const q = this.sql;\n const now = this.now(q);\n const byToken = token === undefined ? q`1 = 1` : q`token = ${token}`;\n const result = await q`\n UPDATE ${this.name(q)}\n SET owner = '', expires_at = 0, updated_at = ${now}\n WHERE name = ${name} AND owner = ${owner} AND ${byToken} AND expires_at > ${now}\n `;\n return affected(result) > 0;\n }\n\n async holder(name: string): Promise<{ owner: string; token: number } | null> {\n await this.configure();\n const q = this.sql;\n const [row] = (await q`\n SELECT owner, token FROM ${this.name(q)}\n WHERE name = ${name} AND expires_at > ${this.now(q)}\n `) as Array<{ owner: unknown; token: unknown }>;\n return row ? { owner: String(row.owner), token: Number(row.token) } : null;\n }\n\n async held(name: string, owner: string, token: number): Promise<boolean> {\n await this.configure();\n const q = this.sql;\n const rows = (await q`\n SELECT 1 AS held FROM ${this.name(q)}\n WHERE name = ${name} AND owner = ${owner} AND token = ${token} AND expires_at > ${this.now(q)}\n `) as unknown[];\n return rows.length > 0;\n }\n\n async advance(name: string, value: number): Promise<boolean> {\n await this.configure();\n const q = this.sql;\n await this.seed(q, name);\n const result = await q`\n UPDATE ${this.name(q)}\n SET token = ${this.int(q, value)}, updated_at = ${this.now(q)}\n WHERE name = ${name} AND token < ${this.int(q, value)}\n `;\n return affected(result) > 0;\n }\n\n async fence<T>(name: string, owner: string, token: number, fn: () => Promise<T>): Promise<T> {\n await this.configure();\n const body = async (tx: SQL) => {\n const now = this.now(tx);\n let ok: boolean;\n if (this.dialect === \"sqlite\") {\n // SQLite has no row locks; a write takes the file's write lock until\n // the commit, which is what keeps another holder out.\n const result = await tx`\n UPDATE ${this.name(tx)} SET updated_at = ${now}\n WHERE name = ${name} AND owner = ${owner} AND token = ${token} AND expires_at > ${now}\n `;\n ok = affected(result) > 0;\n } else {\n const rows = (await tx`\n SELECT 1 AS held FROM ${this.name(tx)}\n WHERE name = ${name} AND owner = ${owner} AND token = ${token} AND expires_at > ${now}\n FOR UPDATE\n `) as unknown[];\n ok = rows.length > 0;\n }\n if (!ok) throw new LockLostError(name, token);\n return fn();\n };\n\n const connection = this.connection;\n if (connection === undefined) {\n return (await this.sql.begin((tx) => body(tx))) as T;\n }\n // An ORM transaction on the store's own connection, so model writes in\n // `fn` join it and commit only while the hold is current.\n return withTransaction(this.sql, (tx) => runOnConnection(connection, () => body(tx)), {\n connection,\n });\n }\n\n /**\n * A fixed window in the lock's row: `token` is the count and `expires_at`\n * the window's end. One guarded `UPDATE` either starts a new window, counts\n * a hit in the current one, or matches nothing because it is full.\n */\n async hit(name: string, limit: number, windowMs: number) {\n await this.configure();\n const q = this.sql;\n const now = this.now(q);\n await this.seed(q, name);\n const window = this.ms(q, Math.max(1, windowMs));\n const result = await q`\n UPDATE ${this.name(q)}\n SET token = CASE WHEN expires_at <= ${now} THEN 1 ELSE token + 1 END,\n expires_at = CASE WHEN expires_at <= ${now} THEN ${now} + ${window} ELSE expires_at END,\n updated_at = ${now}\n WHERE name = ${name} AND (expires_at <= ${now} OR token < ${this.int(q, limit)})\n `;\n const allowed = affected(result) > 0;\n const [row] = (await q`\n SELECT expires_at - ${now} AS reset FROM ${this.name(q)} WHERE name = ${name}\n `) as Array<{ reset: unknown }>;\n return { allowed, resetInMs: Math.max(0, Number(row?.reset ?? 0)) };\n }\n\n async refund(name: string) {\n await this.configure();\n const q = this.sql;\n const now = this.now(q);\n await q`\n UPDATE ${this.name(q)} SET token = token - 1, updated_at = ${now}\n WHERE name = ${name} AND token > 0 AND expires_at > ${now}\n `;\n }\n\n /**\n * Deletes locks that are free and were last touched more than `olderThanMs`\n * ago, and resolves to how many. Tokens start again from 1 for a pruned\n * name, so keep `olderThanMs` far above any lease.\n */\n async prune(olderThanMs: number): Promise<number> {\n await this.configure();\n const q = this.sql;\n const now = this.now(q);\n const result = await q`\n DELETE FROM ${this.name(q)}\n WHERE expires_at <= ${now} AND updated_at <= ${now} - ${this.ms(q, olderThanMs)}\n `;\n return affected(result);\n }\n\n /** Makes sure the name has a row, free, so the guarded `UPDATE`s have something to match. */\n private async seed(q: SQL, name: string) {\n const now = this.now(q);\n if (this.mysql) {\n await q`\n INSERT IGNORE INTO ${this.name(q)} (name, owner, token, expires_at, updated_at)\n VALUES (${name}, '', 0, 0, ${now})\n `;\n return;\n }\n await q`\n INSERT INTO ${this.name(q)} (name, owner, token, expires_at, updated_at)\n VALUES (${name}, '', 0, 0, ${now})\n ON CONFLICT (name) DO NOTHING\n `;\n }\n\n private get mysql() {\n return this.dialect === \"mysql\" || this.dialect === \"mariadb\";\n }\n\n /** See `DatabaseQueueDriver.configure`. */\n private configure(): Promise<void> {\n if (this.dialect !== \"sqlite\" || this.busyTimeout === 0) return Promise.resolve();\n this.configured ??= (async () => {\n const [current] = (await this.sql.unsafe(\"PRAGMA busy_timeout\")) as Array<{\n timeout: number | string;\n }>;\n if (Number(current?.timeout ?? 0) !== 0) return;\n await this.sql.unsafe(`PRAGMA busy_timeout = ${this.busyTimeout}`);\n })().catch((error) => {\n this.configured = undefined;\n throw error;\n });\n return this.configured;\n }\n\n private name(q: SQL) {\n return q.unsafe(this.mysql ? `\\`${this.table}\\`` : `\"${this.table}\"`);\n }\n\n /** The database's clock in epoch milliseconds, as the queue driver reads it. */\n private now(q: SQL) {\n switch (this.dialect) {\n case \"postgres\":\n return q`floor(extract(epoch from statement_timestamp()) * 1000)::bigint`;\n case \"mysql\":\n case \"mariadb\":\n return q`(TIMESTAMPDIFF(MICROSECOND, '1970-01-01 00:00:00', UTC_TIMESTAMP(6)) DIV 1000)`;\n case \"sqlite\":\n return q`CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER)`;\n }\n }\n\n private ms(q: SQL, value: number) {\n return this.int(q, Math.max(0, Math.round(value)));\n }\n\n private int(q: SQL, value: number) {\n const n = Math.round(value);\n return this.mysql ? q`CAST(${n} AS SIGNED)` : q`CAST(${n} AS BIGINT)`;\n }\n}\n\nfunction affected(result: unknown): number {\n const counts = result as { count?: number | null; affectedRows?: number | null };\n return Math.max(Number(counts.count ?? 0), Number(counts.affectedRows ?? 0));\n}\n\n/** The locks table, as Prisma generates it for the model in the docs, with `IF NOT EXISTS`. */\nexport function createLockTableStatements(dialect: Dialect, table: string): string[] {\n if (dialect === \"mysql\" || dialect === \"mariadb\") {\n return [\n `CREATE TABLE IF NOT EXISTS \\`${table}\\` (\n \\`name\\` VARCHAR(191) NOT NULL,\n \\`owner\\` VARCHAR(191) NOT NULL,\n \\`token\\` BIGINT NOT NULL DEFAULT 0,\n \\`expires_at\\` BIGINT NOT NULL,\n \\`updated_at\\` BIGINT NOT NULL,\n\n PRIMARY KEY (\\`name\\`)\n) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci`,\n ];\n }\n const key = dialect === \"sqlite\" ? `\"name\" TEXT NOT NULL PRIMARY KEY,` : `\"name\" TEXT NOT NULL,`;\n const constraint =\n dialect === \"sqlite\" ? \"\" : `,\\n\\n CONSTRAINT \"${table}_pkey\" PRIMARY KEY (\"name\")`;\n return [\n `CREATE TABLE IF NOT EXISTS \"${table}\" (\n ${key}\n \"owner\" TEXT NOT NULL,\n \"token\" BIGINT NOT NULL DEFAULT 0,\n \"expires_at\" BIGINT NOT NULL,\n \"updated_at\" BIGINT NOT NULL${constraint}\n)`,\n ];\n}\n",
|
|
6
6
|
"import { LockLostError, type LockStore } from \"./LockStore\";\n\ntype Entry = {\n owner: string;\n token: number;\n expiresAt: number;\n /** Running `fence` calls. A fenced lock cannot change hands, lease or not. */\n fences: number;\n};\n\n/**\n * Locks in this process's memory. Correct for one process and useless across\n * several: two servers each have their own map, so each takes every lock. It\n * is what the queue uses with the memory driver, and in tests.\n */\nexport class MemoryLockStore implements LockStore {\n private readonly entries = new Map<string, Entry>();\n private readonly counters = new Map<string, number>();\n\n async acquire(name: string, owner: string, ttlMs: number): Promise<number | null> {\n const now = Date.now();\n const entry = this.entries.get(name);\n if (entry && (entry.expiresAt > now || entry.fences > 0)) return null;\n const token = (entry?.token ?? 0) + 1;\n this.entries.set(name, { owner, token, expiresAt: now + Math.max(0, ttlMs), fences: 0 });\n return token;\n }\n\n async extend(name: string, owner: string, token: number, ttlMs: number): Promise<boolean> {\n const entry = this.current(name, owner, token);\n if (!entry) return false;\n entry.expiresAt = Date.now() + Math.max(0, ttlMs);\n return true;\n }\n\n async release(name: string, owner: string, token?: number): Promise<boolean> {\n const entry = this.current(name, owner, token);\n if (!entry) return false;\n entry.owner = \"\";\n entry.expiresAt = 0;\n return true;\n }\n\n async holder(name: string) {\n const entry = this.entries.get(name);\n if (!entry || entry.expiresAt <= Date.now()) return null;\n return { owner: entry.owner, token: entry.token };\n }\n\n async held(name: string, owner: string, token: number): Promise<boolean> {\n return this.current(name, owner, token) !== undefined;\n }\n\n async advance(name: string, value: number): Promise<boolean> {\n if ((this.counters.get(name) ?? -Infinity) >= value) return false;\n this.counters.set(name, value);\n return true;\n }\n\n async fence<T>(name: string, owner: string, token: number, fn: () => Promise<T>): Promise<T> {\n const entry = this.current(name, owner, token);\n if (!entry) throw new LockLostError(name, token);\n entry.fences++;\n try {\n return await fn();\n } finally {\n entry.fences--;\n }\n }\n\n private readonly windows = new Map<string, { count: number; endsAt: number }>();\n\n async hit(name: string, limit: number, windowMs: number) {\n const now = Date.now();\n let window = this.windows.get(name);\n if (!window || window.endsAt <= now) {\n window = { count: 0, endsAt: now + Math.max(1, windowMs) };\n this.windows.set(name, window);\n }\n if (window.count >= limit) return { allowed: false, resetInMs: window.endsAt - now };\n window.count++;\n return { allowed: true, resetInMs: window.endsAt - now };\n }\n\n async refund(name: string) {\n const window = this.windows.get(name);\n if (window && window.endsAt > Date.now() && window.count > 0) window.count--;\n }\n\n private current(name: string, owner: string, token?: number) {\n const entry = this.entries.get(name);\n if (!entry || entry.owner !== owner || entry.expiresAt <= Date.now()) return undefined;\n if (token !== undefined && entry.token !== token) return undefined;\n return entry;\n }\n}\n",
|
|
@@ -12,13 +12,12 @@
|
|
|
12
12
|
"import type { EnqueueBatch, EnqueueJob } from \"../QueueDriver\";\nimport {\n type AcquireResult,\n type StepRecord,\n WORKFLOW_TICK_JOB,\n type WorkflowChange,\n WorkflowLeaseLostError,\n sameTick,\n type WorkflowRecord,\n type WorkflowState,\n type WorkflowStore,\n} from \"./WorkflowStore\";\n\n/** What the memory driver lends its workflow store: its own writes, done synchronously. */\nexport type MemoryQueueWrites = {\n enqueue(job: EnqueueJob): void;\n enqueueBatch(batch: EnqueueBatch): void;\n cancelBatch(id: string): void;\n};\n\n/** How long an ended workflow is kept for `find`. */\nconst FINISHED_WORKFLOW_TTL = 24 * 60 * 60_000;\n\n/**\n * Workflows in this process's memory, beside the memory driver's jobs, and\n * lost with them when the process exits. Every change happens synchronously\n * inside the call that makes it, so it is atomic without further care.\n */\nexport class MemoryWorkflowStore implements WorkflowStore {\n private workflows = new Map<string, WorkflowRecord>();\n private steps = new Map<string, Map<string, StepRecord>>();\n\n constructor(private readonly queue: MemoryQueueWrites) {}\n\n async create(workflow: { id: string; name: string; args: string }): Promise<void> {\n if (this.workflows.has(workflow.id)) {\n throw new Error(`A workflow with the id ${workflow.id} already exists.`);\n }\n // Nothing else removes an ended workflow, and a long-running process\n // would otherwise keep every one it ever ran.\n void this.prune(FINISHED_WORKFLOW_TTL);\n const now = Date.now();\n this.workflows.set(workflow.id, {\n ...workflow,\n status: \"running\",\n currentStep: null,\n progress: 0,\n result: null,\n error: null,\n wakeAt: null,\n lockedBy: null,\n lockedUntil: null,\n retick: false,\n createdAt: now,\n updatedAt: now,\n });\n this.steps.set(workflow.id, new Map());\n this.tick(workflow.id, 0);\n }\n\n async find(id: string, options: { steps?: boolean } = {}): Promise<WorkflowState | null> {\n const workflow = this.workflows.get(id);\n if (!workflow) return null;\n return {\n workflow: { ...workflow },\n steps: options.steps === false ? [] : this.stepsOf(id),\n };\n }\n\n async acquire(id: string, owner: string, leaseMs: number): Promise<AcquireResult> {\n const workflow = this.workflows.get(id);\n if (!workflow) return { kind: \"missing\" };\n const now = Date.now();\n if (\n workflow.lockedBy !== null &&\n !sameTick(workflow.lockedBy, owner) &&\n (workflow.lockedUntil ?? 0) > now\n ) {\n workflow.retick = true;\n return { kind: \"busy\" };\n }\n workflow.lockedBy = owner;\n workflow.lockedUntil = now + leaseMs;\n workflow.retick = false;\n return { kind: \"acquired\", workflow: { ...workflow }, steps: this.stepsOf(id) };\n }\n\n async renew(id: string, owner: string, leaseMs: number): Promise<boolean> {\n const workflow = this.workflows.get(id);\n if (!workflow || workflow.lockedBy !== owner) return false;\n workflow.lockedUntil = Date.now() + leaseMs;\n return true;\n }\n\n async update<T>(\n id: string,\n options: { owner?: string; key?: string; allSteps?: boolean },\n decide: (snapshot: {\n workflow: WorkflowRecord;\n step: StepRecord | null;\n steps: StepRecord[];\n now: number;\n }) => WorkflowChange<T>,\n ): Promise<T | undefined> {\n const workflow = this.workflows.get(id);\n if (!workflow) return undefined;\n if (options.owner !== undefined && workflow.lockedBy !== options.owner) {\n throw new WorkflowLeaseLostError(id);\n }\n const steps = this.steps.get(id)!;\n const current = options.key === undefined ? undefined : steps.get(options.key);\n const now = Date.now();\n const change = decide({\n workflow: { ...workflow },\n step: current ? { ...current } : null,\n steps: options.allSteps ? this.stepsOf(id) : [],\n now,\n });\n\n if (change.step) {\n const previous = steps.get(change.step.key);\n // A Map keeps insertion order, so a step keeps its first-recorded place.\n steps.set(change.step.key, { ...change.step, createdAt: previous?.createdAt ?? now, updatedAt: now });\n }\n if (change.batch) this.queue.enqueueBatch(change.batch);\n for (const batchId of change.cancelBatches ?? []) this.queue.cancelBatch(batchId);\n if (change.workflow) Object.assign(workflow, change.workflow);\n workflow.updatedAt = now;\n if (change.tick) this.tick(id, change.tick.delayMs);\n if (change.unlock) {\n workflow.lockedBy = null;\n workflow.lockedUntil = null;\n if (workflow.retick) {\n workflow.retick = false;\n this.tick(id, 0);\n }\n }\n return change.result;\n }\n\n async prune(olderThanMs: number): Promise<number> {\n const cutoff = Date.now() - olderThanMs;\n let count = 0;\n for (const [id, workflow] of this.workflows) {\n const ended = [\"completed\", \"failed\", \"cancelled\"].includes(workflow.status);\n if (ended && workflow.updatedAt <= cutoff) {\n this.workflows.delete(id);\n this.steps.delete(id);\n count++;\n }\n }\n return count;\n }\n\n private stepsOf(id: string): StepRecord[] {\n return [...(this.steps.get(id)?.values() ?? [])].map((step) => ({ ...step }));\n }\n\n private tick(id: string, delayMs: number) {\n this.queue.enqueue({\n name: WORKFLOW_TICK_JOB,\n args: JSON.stringify([id]),\n delayMs: Math.max(0, Math.round(delayMs)),\n });\n }\n}\n",
|
|
13
13
|
"import {\n type BatchOutcome,\n type BatchRecord,\n type BatchStatus,\n cancelsBatch,\n clampProgress,\n countOutcome,\n markCancelled,\n newBatchRecord,\n settle,\n statusOf,\n} from \"./batch\";\nimport type {\n ClaimOptions,\n ClaimedJob,\n EnqueueBatch,\n EnqueueJob,\n JobFailure,\n JobRelease,\n QueueDriver,\n} from \"./QueueDriver\";\nimport { MemoryWorkflowStore } from \"./workflow/MemoryWorkflowStore\";\nimport type { WorkflowStore } from \"./workflow/WorkflowStore\";\n\ntype Entry = {\n job: ClaimedJob;\n /** Waiting: when it becomes due. Leased: when the lease runs out. */\n until: number;\n leased: boolean;\n /** Tie-break for `until`, so jobs that became claimable together stay FIFO. */\n seq: number;\n /** What a job of a batch last reported with `this.progress()`. */\n progress: number;\n};\n\n/**\n * How long a finished batch is kept for `findBatch`. Nothing else removes\n * one, and a long-running process would otherwise keep every batch it ever\n * ran.\n */\nconst FINISHED_BATCH_TTL = 24 * 60 * 60_000;\n\n/**\n * The default driver: a Map in this process's memory.\n *\n * **Everything in it is lost when the process exits.** A job that is waiting,\n * one waiting out a retry's backoff, and one halfway through `run` all vanish\n * with the process, and no hook fires for any of them — `Job.dispatch()`\n * resolved long ago, so nothing upstream is told. A deploy, a scale-in or a\n * crash is enough. Use it for development, tests, and work that is safe to\n * lose; anything that is not needs a driver backed by storage that outlives\n * the process.\n *\n * It implements the whole claim contract anyway — leases, reclaim on expiry,\n * stale-claim rejection — rather than the subset one process strictly needs.\n * That keeps it a faithful stand-in for a persistent driver in tests, and lets\n * the shared contract suite run against it unchanged. A lease can only lapse\n * here if the event loop was blocked for longer than the visibility timeout,\n * since the manager heartbeats every job it is running.\n *\n * It ignores `registered` in `claim` and hands out every name. Nothing but\n * this process can run its jobs, so a name this process does not know will\n * not be known by anyone, and the manager dead-letters it at once with a line\n * saying so; filtered out, it would wait here unseen until the process exited.\n *\n * Batches are kept in a Map beside the jobs, and a finished one for a day.\n * Everything a batch does happens synchronously inside the call that causes\n * it, so the counters and the callbacks need no further care here.\n *\n * One timer at most, for the next moment something becomes claimable, and it\n * is unref'd: a queue with nothing due does not hold the process open, and\n * neither does one waiting out a backoff — the same way the queue never has.\n */\nexport class MemoryQueueDriver implements QueueDriver {\n private entries = new Map<string, Entry>();\n private batches = new Map<string, BatchRecord>();\n private workflows: MemoryWorkflowStore | undefined;\n private listeners = new Set<() => void>();\n private timer: ReturnType<typeof setTimeout> | undefined;\n private timerAt = Infinity;\n private seq = 0;\n\n /** Jobs waiting to be claimed, including ones not yet due. */\n get waiting(): number {\n let count = 0;\n for (const entry of this.entries.values()) if (!entry.leased) count++;\n return count;\n }\n\n /** Jobs currently claimed and not yet reported on. */\n get leased(): number {\n return this.entries.size - this.waiting;\n }\n\n async enqueue(job: EnqueueJob): Promise<string> {\n const id = this.add(job);\n this.changed();\n return id;\n }\n\n private add(\n { name, args, delayMs = 0, id = crypto.randomUUID() }: EnqueueJob,\n batchId?: string,\n ): string {\n const now = Date.now();\n this.entries.set(id, {\n job: {\n id,\n name,\n args,\n attempt: 0,\n createdAt: now,\n ...(batchId === undefined ? {} : { batchId }),\n },\n until: now + Math.max(0, delayMs),\n leased: false,\n seq: this.seq++,\n progress: 0,\n });\n return id;\n }\n\n async enqueueBatch(batch: EnqueueBatch): Promise<void> {\n this.recordBatch(batch);\n }\n\n /** `enqueueBatch`, synchronously, for the workflow store too. */\n private recordBatch(batch: EnqueueBatch) {\n const now = Date.now();\n this.forgetFinishedBatches(now);\n const record = newBatchRecord({ ...batch, total: batch.args.length, now });\n for (const args of batch.args) this.add({ name: batch.job, args }, batch.id);\n // A batch of no jobs is finished as soon as it exists.\n const { record: settled, calls } = settle(record, record, now);\n this.batches.set(batch.id, settled);\n for (const call of calls) this.add(call);\n this.changed();\n }\n\n async findBatch(id: string, options: { progress?: boolean } = {}): Promise<BatchStatus | null> {\n const record = this.batches.get(id);\n if (!record) return null;\n if (options.progress === false || record.pending === 0) return statusOf(record);\n let running = 0;\n for (const entry of this.entries.values()) {\n if (entry.job.batchId === id) running += entry.progress;\n }\n return statusOf(record, running);\n }\n\n async cancelBatch(id: string): Promise<boolean> {\n return this.cancelBatchNow(id);\n }\n\n private cancelBatchNow(id: string): boolean {\n const prev = this.batches.get(id);\n if (!prev || prev.finishedAt !== null || prev.cancelledAt !== null) return false;\n const now = Date.now();\n const next = markCancelled(prev, now, this.cancelWaiting(id));\n this.save(prev, next, now);\n this.changed();\n return true;\n }\n\n /**\n * Workflows (#846), kept in memory beside the jobs and lost with them. The\n * store's writes, ticks and batches included, happen synchronously here.\n */\n workflowStore(): WorkflowStore {\n this.workflows ??= new MemoryWorkflowStore({\n enqueue: (job) => {\n this.add(job);\n this.changed();\n },\n enqueueBatch: (batch) => this.recordBatch(batch),\n cancelBatch: (id) => void this.cancelBatchNow(id),\n });\n return this.workflows;\n }\n\n async reportProgress(job: ClaimedJob, progress: number): Promise<void> {\n const entry = this.current(job);\n if (entry) entry.progress = clampProgress(progress);\n }\n\n async claim(limit: number, options: ClaimOptions): Promise<ClaimedJob[]> {\n const now = Date.now();\n const due = [...this.entries.values()]\n .filter((entry) => entry.until <= now)\n .sort((a, b) => a.until - b.until || a.seq - b.seq)\n .slice(0, Math.max(0, limit));\n\n for (const entry of due) {\n entry.job = { ...entry.job, attempt: entry.job.attempt + 1 };\n entry.leased = true;\n entry.until = now + options.visibilityTimeoutMs;\n }\n if (due.length > 0) this.schedule();\n\n // Copies, so a caller holding one cannot move the record underneath us.\n return due.map((entry) => ({ ...entry.job }));\n }\n\n async complete(job: ClaimedJob): Promise<void> {\n const entry = this.current(job);\n if (!entry) return;\n this.entries.delete(job.id);\n this.count(entry, \"succeeded\");\n this.schedule();\n }\n\n async fail(job: ClaimedJob, failure: JobFailure): Promise<void> {\n const entry = this.current(job);\n if (!entry) return;\n\n // A retry of a job whose batch was cancelled meanwhile would only be\n // ended as cancelled when it was next claimed; ended here instead.\n const batch = entry.job.batchId === undefined ? undefined : this.batches.get(entry.job.batchId);\n const cancelled =\n failure.cancelled === true || (failure.retryInMs !== null && batch?.cancelledAt != null);\n\n if (failure.retryInMs === null || cancelled) {\n this.entries.delete(job.id);\n this.count(entry, cancelled ? \"cancelled\" : \"failed\");\n this.schedule();\n return;\n }\n\n entry.leased = false;\n entry.until = Date.now() + Math.max(0, failure.retryInMs);\n entry.seq = this.seq++;\n entry.progress = 0;\n this.changed();\n }\n\n async release(job: ClaimedJob, release: JobRelease): Promise<void> {\n const entry = this.current(job);\n if (!entry) return;\n\n entry.job = { ...entry.job, attempt: entry.job.attempt - 1 };\n entry.leased = false;\n entry.until = Date.now() + Math.max(0, release.retryInMs);\n entry.seq = this.seq++;\n this.changed();\n }\n\n async heartbeat(jobs: ClaimedJob[], options: ClaimOptions): Promise<void> {\n const until = Date.now() + options.visibilityTimeoutMs;\n for (const job of jobs) {\n const entry = this.current(job);\n if (entry) entry.until = until;\n }\n this.schedule();\n }\n\n /** Counts a job's end against its batch, if it has one. */\n private count(entry: Entry, outcome: BatchOutcome) {\n const batchId = entry.job.batchId;\n if (batchId === undefined) return;\n const prev = this.batches.get(batchId);\n if (!prev) return;\n const now = Date.now();\n let next = countOutcome(prev, outcome, entry.job.id);\n if (cancelsBatch(prev, next)) {\n next = markCancelled(next, now, this.cancelWaiting(batchId));\n }\n this.save(prev, next, now);\n this.changed();\n }\n\n /** Stores the batch's new state and enqueues the callbacks it made due. */\n private save(prev: BatchRecord, next: BatchRecord, now: number) {\n const { record, calls } = settle(prev, next, now);\n this.batches.set(record.id, record);\n for (const call of calls) this.add(call);\n }\n\n /** Drops the batch's waiting jobs, and says how many there were. */\n private cancelWaiting(batchId: string): number {\n let count = 0;\n for (const [id, entry] of this.entries) {\n if (entry.job.batchId === batchId && !entry.leased) {\n this.entries.delete(id);\n count++;\n }\n }\n return count;\n }\n\n private forgetFinishedBatches(now: number) {\n for (const [id, record] of this.batches) {\n if (record.finishedAt !== null && now - record.finishedAt > FINISHED_BATCH_TTL) {\n this.batches.delete(id);\n }\n }\n }\n\n subscribe(wake: () => void): () => void {\n this.listeners.add(wake);\n return () => void this.listeners.delete(wake);\n }\n\n /**\n * The entry for a report, if the report is about the claim that currently\n * holds it. A stale claimer — one whose lease lapsed and was re-issued —\n * gets nothing, so its late `complete` cannot end the newer claim.\n */\n private current(job: ClaimedJob): Entry | undefined {\n const entry = this.entries.get(job.id);\n if (!entry || !entry.leased || entry.job.attempt !== job.attempt) {\n return undefined;\n }\n return entry;\n }\n\n private changed() {\n this.schedule();\n const now = Date.now();\n for (const entry of this.entries.values()) {\n if (entry.until <= now) {\n this.wake();\n return;\n }\n }\n }\n\n private wake() {\n for (const listener of [...this.listeners]) listener();\n }\n\n /** Points the one timer at the next moment something becomes claimable. */\n private schedule() {\n const now = Date.now();\n let next = Infinity;\n for (const entry of this.entries.values()) {\n if (entry.until > now && entry.until < next) next = entry.until;\n }\n if (next === this.timerAt) return;\n\n clearTimeout(this.timer);\n this.timer = undefined;\n this.timerAt = next;\n if (next === Infinity) return;\n\n this.timer = setTimeout(() => {\n this.timer = undefined;\n this.timerAt = Infinity;\n this.changed();\n }, next - now);\n this.timer.unref?.();\n }\n}\n",
|
|
14
14
|
"/**\n * The delay before the retry that follows attempt `attempt`: the number\n * itself, or the array's entry for that retry with its last entry repeated.\n */\nexport function backoffFor(backoff: number | number[], attempt: number) {\n const delay = Array.isArray(backoff)\n ? backoff[Math.min(attempt, backoff.length) - 1]\n : backoff;\n return Math.max(0, delay ?? 0);\n}\n",
|
|
15
|
-
"/**\n * A length of time: milliseconds as a number, or a number and a unit, such as\n * `\"500ms\"`, `\"30s\"`, `\"5m\"`, `\"2h\"`, `\"7d\"` or `\"1w\"`.\n */\nexport type Duration = number | `${number}${\"ms\" | \"s\" | \"m\" | \"h\" | \"d\" | \"w\"}`;\n\nconst UNITS: Record<string, number> = {\n ms: 1,\n s: 1000,\n m: 60_000,\n h: 60 * 60_000,\n d: 24 * 60 * 60_000,\n w: 7 * 24 * 60 * 60_000,\n};\n\n/** A `Duration` in milliseconds. Throws for anything else, on the caller's stack. */\nexport function toMilliseconds(duration: Duration): number {\n if (typeof duration === \"number\") {\n if (!Number.isFinite(duration) || duration < 0) {\n throw new TypeError(`A duration is 0 or more milliseconds; got ${duration}.`);\n }\n return Math.round(duration);\n }\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(ms|s|m|h|d|w)\\s*$/.exec(String(duration));\n if (!match) {\n throw new TypeError(\n `\"${String(duration)}\" is not a duration. Use milliseconds, or a number and ` +\n `one of ms, s, m, h, d, w (\"30s\", \"7d\").`,\n );\n }\n return Math.round(Number(match[1]) * UNITS[match[2]!]!);\n}\n",
|
|
16
15
|
"import { backoffFor } from \"../backoff\";\nimport { type BatchStatus, clampProgress } from \"../batch\";\nimport type { EnqueueBatch } from \"../QueueDriver\";\nimport type { Job } from \"../Job\";\nimport { type Duration, toMilliseconds } from \"./duration\";\nimport {\n type StepRecord,\n type StepRunStatus,\n WORKFLOW_OUTPUT_LIMIT,\n type WorkflowChange,\n WorkflowLeaseLostError,\n type WorkflowSnapshot,\n type WorkflowStore,\n} from \"./WorkflowStore\";\n\n/** What a `step.run` function is handed. */\nexport type StepContext = {\n /**\n * `<workflow id>:<step key>`: the same on every attempt of this step, and\n * different for every other step. Pass it to a payment provider, say, so\n * that an attempt repeated after a crash is not charged twice.\n */\n idempotencyKey: string;\n /** Which attempt this is, counting from 1. */\n attempt: number;\n /**\n * Aborted when the step's `timeout` passes or the workflow is cancelled.\n * Pass it to `fetch` and friends. The workflow stops waiting for the step\n * at that moment, whether or not the function notices.\n */\n signal: AbortSignal;\n};\n\nexport type StepRunOptions = {\n /** How many attempts the step gets, counting the first. Default 3. */\n attempts?: number;\n /**\n * Milliseconds to wait before each retry: one number for every retry, or\n * one per retry with the last repeated, as `Job.backoff`. Default 0. A\n * retry with a delay suspends the workflow until it is due.\n */\n backoff?: number | number[];\n /** How long one attempt may take before it counts as failed. */\n timeout?: Duration;\n};\n\nexport type StepWaitOptions = {\n /**\n * How long to wait for the signal. Past it, `waitFor` throws a\n * `WaitTimeoutError`. Without it, the workflow waits until it is signalled\n * or cancelled.\n */\n timeout?: Duration;\n};\n\nexport type StepBatchOptions = {\n /** A label kept with the batch. Default `workflow:<id>:<key>`. */\n name?: string;\n /**\n * Whether a failed job leaves the rest running. Default `false`: the first\n * dead-lettered job cancels the batch and `step.batch` throws a\n * `StepFailedError`. With `true`, `step.batch` returns the status, failed\n * jobs and all.\n */\n allowFailures?: boolean;\n};\n\n/** A step that ran out of attempts, or a batch that failed. */\nexport class StepFailedError extends Error {\n constructor(\n /** The step's key. */\n readonly step: string,\n message: string,\n /** The batch's final status, for a `step.batch` that failed. */\n readonly batch?: BatchStatus,\n ) {\n super(message);\n this.name = \"StepFailedError\";\n }\n}\n\n/** A `step.waitFor` whose `timeout` passed before the signal arrived. */\nexport class WaitTimeoutError extends Error {\n constructor(readonly step: string) {\n super(`No signal \"${step}\" arrived before its timeout.`);\n this.name = \"WaitTimeoutError\";\n }\n}\n\n/** Why a step's `ctx.signal` was aborted by its `timeout`. */\nexport class StepTimeoutError extends Error {\n constructor(step: string, timeoutMs: number) {\n super(`Step \"${step}\" took longer than its timeout of ${timeoutMs}ms.`);\n this.name = \"StepTimeoutError\";\n }\n}\n\n/** Why a step's `ctx.signal` was aborted by `Workflow.cancel`. */\nexport class WorkflowCancelledError extends Error {\n constructor(id: string) {\n super(`Workflow ${id} was cancelled.`);\n this.name = \"WorkflowCancelledError\";\n }\n}\n\n/**\n * Thrown through the workflow's code when a step cannot finish in this tick\n * (a sleep, a wait, a batch, a retry with a delay), so the tick can end and\n * the workflow resume later. Not exported: code that catches everything\n * should rethrow what it does not know, and the tick treats the workflow as\n * suspended even if this is swallowed.\n */\nexport class WorkflowSuspended extends Error {\n constructor() {\n super(\n \"The workflow is suspended until a step can continue. Rethrow this \" +\n \"error if you catch it.\",\n );\n this.name = \"WorkflowSuspended\";\n }\n}\n\n/** What the runtime gives the steps of one tick. */\nexport type StepTick = {\n workflowId: string;\n /** The tick's hold on the workflow; every write is fenced by it. */\n owner: string;\n store: WorkflowStore;\n /** The steps as they were when the tick took the workflow. */\n steps: StepRecord[];\n /** This tick runs `onCancel`, not `run`. */\n cancelling: boolean;\n findBatch(id: string): Promise<BatchStatus | null>;\n buildBatch(\n job: new () => Job,\n args: ReadonlyArray<ReadonlyArray<unknown>>,\n options: { name: string; allowFailures: boolean },\n ): EnqueueBatch;\n /** Jobs were recorded: wake the queue. */\n scheduled(): void;\n /** How often a running step checks whether the workflow was cancelled. */\n cancelCheckMs: number;\n};\n\n/** Why a tick stopped where it did. */\nexport type Suspension = {\n status: \"sleeping\" | \"waiting\";\n /** When a tick is needed to continue; none for a wait on a signal or batch. */\n wakes: number[];\n};\n\nconst DONE = Symbol(\"done\");\n\n/**\n * What `run` receives as its first argument. Every method takes a **key**,\n * unique within the workflow and the same on every pass: a step whose key has\n * a stored result returns it without running again, which is how a workflow\n * resumes where it stopped. Code outside the steps runs again on every pass.\n */\nexport class Step {\n /** The workflow's id. */\n readonly workflowId: string;\n\n private readonly steps: Map<string, StepRecord>;\n private readonly seen = new Set<string>();\n private readonly pending = new Set<Promise<unknown>>();\n /** @internal Why the tick stopped, once a step suspended it. */\n suspension: Suspension | undefined;\n /** @internal The tick lost its hold on the workflow. */\n lost = false;\n /** The workflow was cancelled during this tick. */\n private cancelled = false;\n /** @internal The step the workflow is on, for its status. */\n current: string | null = null;\n\n /** @internal Built by the workflow runtime, once per tick. */\n constructor(private readonly tick: StepTick) {\n this.workflowId = tick.workflowId;\n this.steps = new Map(tick.steps.map((step) => [step.key, step]));\n }\n\n /**\n * Runs `fn` once and stores what it returns, as JSON; on every later pass\n * the stored value is returned without running it again. A throw is retried\n * up to `attempts`, after which the step fails and this throws a\n * `StepFailedError`, which the workflow may catch. The value comes back as\n * JSON makes it, the first time too: a `Date` becomes a string.\n *\n * At least once: a process that dies after `fn` and before its result is\n * stored runs it again. Use `ctx.idempotencyKey` for anything that must not\n * happen twice, or `attempts: 1`.\n */\n run<T>(\n key: string,\n fn: (ctx: StepContext) => T | Promise<T>,\n options: StepRunOptions = {},\n ): Promise<Awaited<T>> {\n return this.track(key, () => this.runStep(key, fn, options)) as Promise<Awaited<T>>;\n }\n\n /** Suspends the workflow for `duration`, without holding a process. */\n sleep(key: string, duration: Duration): Promise<void> {\n const ms = toMilliseconds(duration);\n return this.track(key, () => this.sleepStep(key, ms));\n }\n\n /**\n * Suspends the workflow until `Workflow.signal(id, key, payload)` and\n * returns the payload. A signal that arrives before the workflow gets here\n * is kept, and returned at once.\n */\n waitFor<T = unknown>(key: string, options: StepWaitOptions = {}): Promise<T> {\n const timeout = options.timeout === undefined ? undefined : toMilliseconds(options.timeout);\n return this.track(key, () => this.waitStep(key, timeout)) as Promise<T>;\n }\n\n /**\n * Dispatches `job` once per argument tuple as a batch (`Job.dispatchBatch`)\n * and suspends the workflow until every job has ended; then returns the\n * batch's status. The step is recorded and the batch dispatched in one\n * atomic write, so a crash cannot dispatch it twice.\n */\n batch<J extends Job>(\n key: string,\n job: new () => J,\n args: ReadonlyArray<Readonly<Parameters<J[\"run\"]>>>,\n options: StepBatchOptions = {},\n ): Promise<BatchStatus> {\n return this.track(key, () => this.batchStep(key, job, args, options));\n }\n\n /**\n * Sets the workflow's `progress`, 0 to 1. Not a step: it writes on every\n * pass that reaches it.\n */\n async progress(value: number): Promise<void> {\n const progress = clampProgress(value);\n this.assertRunning();\n const write = this.write(undefined, () => ({ result: undefined, workflow: { progress } }));\n this.remember(write);\n await write;\n }\n\n /** @internal Waits for every step this tick started, however each ended. */\n async settled(): Promise<void> {\n while (this.pending.size > 0) {\n await Promise.allSettled(this.pending);\n }\n }\n\n // ---------------------------------------------------------------------\n\n private track<T>(key: string, body: () => Promise<T>): Promise<T> {\n if (typeof key !== \"string\" || key.length === 0 || key.length > 191) {\n throw new TypeError(\n `A step key is a string of 1 to 191 characters; got ${JSON.stringify(key)}.`,\n );\n }\n if (this.seen.has(key)) {\n throw new Error(\n `Two steps of workflow ${this.workflowId} use the key \"${key}\". Each step ` +\n `needs a key of its own, or the second would return the first one's result.`,\n );\n }\n this.seen.add(key);\n this.assertRunning();\n const promise = body();\n this.remember(promise);\n return promise;\n }\n\n private remember(promise: Promise<unknown>) {\n this.pending.add(promise);\n const forget = () => void this.pending.delete(promise);\n promise.then(forget, forget);\n }\n\n /** Once suspended, nothing else may start in this tick. */\n private assertRunning() {\n if (this.lost) throw new WorkflowLeaseLostError(this.workflowId);\n if (this.suspension) throw new WorkflowSuspended();\n }\n\n private suspend(status: Suspension[\"status\"], wakeAt?: number | null): never {\n if (!this.suspension) this.suspension = { status, wakes: [] };\n if (wakeAt != null) this.suspension.wakes.push(wakeAt);\n throw new WorkflowSuspended();\n }\n\n /**\n * One atomic write, fenced by the tick's hold. A workflow that is being\n * cancelled takes no new work from `run`: the write is skipped and the\n * tick suspended, so `onCancel` runs next.\n */\n private async write<T>(\n key: string | undefined,\n decide: (snapshot: WorkflowSnapshot) => WorkflowChange<T>,\n ): Promise<T> {\n type Wrapped = { value: T } | typeof DONE;\n let outcome: Wrapped | undefined;\n try {\n outcome = await this.tick.store.update<Wrapped>(\n this.tick.workflowId,\n { owner: this.tick.owner, ...(key === undefined ? {} : { key }) },\n (snapshot) => {\n if (snapshot.workflow.status === \"cancelling\" && !this.tick.cancelling) {\n return { result: DONE };\n }\n const change = decide(snapshot);\n return { ...change, result: { value: change.result } };\n },\n );\n } catch (error) {\n if (error instanceof WorkflowLeaseLostError) this.lost = true;\n throw error;\n }\n if (outcome === undefined) {\n this.lost = true;\n throw new WorkflowLeaseLostError(this.tick.workflowId);\n }\n if (outcome === DONE) {\n this.cancelled = true;\n this.suspend(\"waiting\");\n }\n return outcome.value;\n }\n\n private record(key: string, step: StepRecord | null, fields: Partial<StepRecord>): StepRecord {\n const record: StepRecord = {\n workflowId: this.tick.workflowId,\n key,\n status: \"running\",\n attempt: 0,\n output: null,\n error: null,\n batchId: null,\n wakeAt: null,\n startedAt: null,\n finishedAt: null,\n createdAt: 0,\n updatedAt: 0,\n ...step,\n ...fields,\n };\n this.steps.set(key, record);\n return record;\n }\n\n private mismatch(key: string, status: StepRunStatus, wanted: string): never {\n throw new Error(\n `Step \"${key}\" of workflow ${this.tick.workflowId} was recorded as a ` +\n `${status} step, and is now used as ${wanted}. A key belongs to one step; ` +\n `rename one of them.`,\n );\n }\n\n private async runStep<T>(\n key: string,\n fn: (ctx: StepContext) => T | Promise<T>,\n options: StepRunOptions,\n ): Promise<T> {\n const attempts = Math.max(1, Math.floor(options.attempts ?? 3));\n const timeoutMs = options.timeout === undefined ? undefined : toMilliseconds(options.timeout);\n const cached = this.steps.get(key);\n if (cached?.status === \"completed\") return decode(cached.output) as T;\n if (cached?.status === \"failed\") throw failure(key, cached);\n if (cached?.status === \"retrying\" && cached.wakeAt !== null && cached.wakeAt > Date.now()) {\n this.current = key;\n this.suspend(\"sleeping\", cached.wakeAt);\n }\n\n for (;;) {\n type Begin =\n | { kind: \"done\"; output: string | null }\n | { kind: \"failed\"; step: StepRecord }\n | { kind: \"wait\"; wakeAt: number }\n | { kind: \"run\"; attempt: number };\n const begin = await this.write<Begin>(key, ({ workflow, step, now }) => {\n if (step?.status === \"completed\") return { result: { kind: \"done\", output: step.output } };\n if (step?.status === \"failed\") return { result: { kind: \"failed\", step } };\n if (step && step.status !== \"running\" && step.status !== \"retrying\") {\n this.mismatch(key, step.status, \"step.run\");\n }\n if (step?.status === \"retrying\" && step.wakeAt !== null && step.wakeAt > now) {\n return { result: { kind: \"wait\", wakeAt: step.wakeAt } };\n }\n const attempt = (step?.attempt ?? 0) + 1;\n if (attempt > attempts) {\n const failed = this.record(key, step, {\n status: \"failed\",\n error:\n `Attempt ${attempt - 1} of ${attempts} never finished, most likely ` +\n `because the process running it exited.` +\n (step?.error ? ` The last error was: ${step.error}` : \"\"),\n finishedAt: now,\n wakeAt: null,\n });\n return { result: { kind: \"failed\", step: failed }, step: failed };\n }\n const running = this.record(key, step, {\n status: \"running\",\n attempt,\n startedAt: now,\n finishedAt: null,\n wakeAt: null,\n });\n return {\n result: { kind: \"run\", attempt },\n step: running,\n // `onCancel` runs while the workflow is `cancelling`, and stays so.\n workflow:\n workflow.status === \"cancelling\"\n ? { currentStep: key }\n : { currentStep: key, status: \"running\" },\n };\n });\n this.current = key;\n if (begin.kind === \"done\") return decode(begin.output) as T;\n if (begin.kind === \"failed\") throw failure(key, begin.step);\n if (begin.kind === \"wait\") this.suspend(\"sleeping\", begin.wakeAt);\n const attempt = begin.attempt;\n\n let value: T | undefined;\n let error: unknown;\n let retry = true;\n try {\n value = await this.execute(key, fn, attempt, timeoutMs);\n } catch (thrown) {\n error = thrown;\n }\n // Cancelled while the step ran: leave it as it is; `onCancel` is next.\n if (this.cancelled) throw new WorkflowSuspended();\n\n let output: string | null = null;\n if (error === undefined) {\n try {\n output = encode(value, `The result of step \"${key}\"`);\n } catch (tooLarge) {\n error = tooLarge;\n retry = false;\n }\n }\n if (error === undefined) {\n await this.write(key, ({ step, now }) => ({\n result: undefined,\n step: this.record(key, step, {\n status: \"completed\",\n output,\n error: null,\n wakeAt: null,\n finishedAt: now,\n }),\n }));\n return decode(output) as T;\n }\n\n const message = describe(error);\n if (retry && attempt < attempts) {\n const delay = backoffFor(options.backoff ?? 0, attempt);\n const wakeAt = await this.write(key, ({ step, now }) => {\n const at = delay > 0 ? now + delay : null;\n return {\n result: at,\n step: this.record(key, step, { status: \"retrying\", error: message, wakeAt: at }),\n };\n });\n if (wakeAt !== null) this.suspend(\"sleeping\", wakeAt);\n continue;\n }\n\n const failed = await this.write(key, ({ step, now }) => {\n const record = this.record(key, step, {\n status: \"failed\",\n error: message,\n wakeAt: null,\n finishedAt: now,\n });\n return { result: record, step: record };\n });\n throw failure(key, failed);\n }\n }\n\n /**\n * One attempt of a `step.run` function, abandoned when its timeout passes\n * or the workflow is cancelled meanwhile.\n */\n private async execute<T>(\n key: string,\n fn: (ctx: StepContext) => T | Promise<T>,\n attempt: number,\n timeoutMs: number | undefined,\n ): Promise<T> {\n const controller = new AbortController();\n const context: StepContext = {\n idempotencyKey: `${this.tick.workflowId}:${key}`,\n attempt,\n signal: controller.signal,\n };\n const work = Promise.resolve().then(() => fn(context));\n let timer: ReturnType<typeof setTimeout> | undefined;\n let poll: ReturnType<typeof setInterval> | undefined;\n const abandoned = new Promise<never>((_, reject) => {\n const abort = (reason: Error) => {\n controller.abort(reason);\n reject(reason);\n };\n if (timeoutMs !== undefined) {\n timer = setTimeout(() => abort(new StepTimeoutError(key, timeoutMs)), timeoutMs);\n }\n if (!this.tick.cancelling) {\n poll = setInterval(() => {\n this.tick.store\n .find(this.tick.workflowId, { steps: false })\n .then((state) => {\n if (state?.workflow.status !== \"cancelling\" || controller.signal.aborted) return;\n this.cancelled = true;\n if (!this.suspension) this.suspension = { status: \"waiting\", wakes: [] };\n abort(new WorkflowCancelledError(this.tick.workflowId));\n })\n .catch(() => {});\n }, this.tick.cancelCheckMs);\n poll.unref?.();\n }\n });\n try {\n return await Promise.race([work, abandoned]);\n } finally {\n clearTimeout(timer);\n clearInterval(poll);\n // An abandoned attempt may still settle; its outcome is nobody's now.\n work.catch(() => {});\n abandoned.catch(() => {});\n }\n }\n\n private async sleepStep(key: string, ms: number): Promise<void> {\n const cached = this.steps.get(key);\n if (cached?.status === \"completed\") return;\n this.current = key;\n if (cached?.status === \"sleeping\" && cached.wakeAt !== null && cached.wakeAt > Date.now()) {\n this.suspend(\"sleeping\", cached.wakeAt);\n }\n const wakeAt = await this.write<number | null>(key, ({ step, now }) => {\n if (step?.status === \"completed\") return { result: null };\n if (step && step.status !== \"sleeping\") this.mismatch(key, step.status, \"step.sleep\");\n const at = step?.wakeAt ?? now + ms;\n if (at <= now) {\n return {\n result: null,\n step: this.record(key, step, {\n status: \"completed\",\n wakeAt: at,\n startedAt: step?.startedAt ?? now,\n finishedAt: now,\n }),\n };\n }\n if (step) return { result: at };\n return {\n result: at,\n step: this.record(key, null, { status: \"sleeping\", wakeAt: at, startedAt: now }),\n workflow: { currentStep: key },\n };\n });\n if (wakeAt !== null) this.suspend(\"sleeping\", wakeAt);\n }\n\n private async waitStep(key: string, timeoutMs: number | undefined): Promise<unknown> {\n const cached = this.steps.get(key);\n if (cached?.status === \"completed\") return decode(cached.output);\n if (cached?.status === \"timed_out\") throw new WaitTimeoutError(key);\n this.current = key;\n if (\n cached?.status === \"waiting\" &&\n (cached.wakeAt === null || cached.wakeAt > Date.now())\n ) {\n this.suspend(\"waiting\", cached.wakeAt);\n }\n type Outcome =\n | { kind: \"value\"; output: string | null }\n | { kind: \"timeout\" }\n | { kind: \"wait\"; wakeAt: number | null };\n const outcome = await this.write<Outcome>(key, ({ step, now }) => {\n if (step?.status === \"completed\") return { result: { kind: \"value\", output: step.output } };\n if (step?.status === \"timed_out\") return { result: { kind: \"timeout\" } };\n if (step?.status === \"signalled\") {\n return {\n result: { kind: \"value\", output: step.output },\n step: this.record(key, step, {\n status: \"completed\",\n wakeAt: null,\n startedAt: step.startedAt ?? now,\n finishedAt: now,\n }),\n };\n }\n if (step && step.status !== \"waiting\") this.mismatch(key, step.status, \"step.waitFor\");\n if (step) {\n if (step.wakeAt !== null && step.wakeAt <= now) {\n return {\n result: { kind: \"timeout\" },\n step: this.record(key, step, { status: \"timed_out\", finishedAt: now }),\n };\n }\n return { result: { kind: \"wait\", wakeAt: step.wakeAt } };\n }\n const wakeAt = timeoutMs === undefined ? null : now + timeoutMs;\n return {\n result: { kind: \"wait\", wakeAt },\n step: this.record(key, null, { status: \"waiting\", wakeAt, startedAt: now }),\n workflow: { currentStep: key },\n };\n });\n if (outcome.kind === \"value\") return decode(outcome.output);\n if (outcome.kind === \"timeout\") throw new WaitTimeoutError(key);\n this.suspend(\"waiting\", outcome.wakeAt);\n }\n\n private async batchStep<J extends Job>(\n key: string,\n job: new () => J,\n args: ReadonlyArray<Readonly<Parameters<J[\"run\"]>>>,\n options: StepBatchOptions,\n ): Promise<BatchStatus> {\n const allowFailures = options.allowFailures === true;\n let cached = this.steps.get(key);\n if (cached?.status === \"completed\") return decode(cached.output) as BatchStatus;\n if (cached?.status === \"failed\") throw failure(key, cached);\n if (cached && cached.status !== \"batching\") this.mismatch(key, cached.status, \"step.batch\");\n this.current = key;\n\n if (!cached) {\n const batch = this.tick.buildBatch(job, args, {\n name: options.name ?? `workflow:${this.tick.workflowId}:${key}`,\n allowFailures,\n });\n cached = await this.write<StepRecord>(key, ({ step, now }) => {\n if (step) return { result: step };\n const record = this.record(key, null, {\n status: \"batching\",\n batchId: batch.id,\n startedAt: now,\n });\n return { result: record, step: record, batch, workflow: { currentStep: key } };\n });\n this.tick.scheduled();\n if (cached.status === \"completed\") return decode(cached.output) as BatchStatus;\n if (cached.status === \"failed\") throw failure(key, cached);\n }\n\n const status = cached.batchId === null ? null : await this.tick.findBatch(cached.batchId);\n if (status && status.finishedAt === null) this.suspend(\"waiting\");\n\n const succeeded =\n status !== null && status.cancelledAt === null && (status.failed === 0 || allowFailures);\n const output = status === null ? null : JSON.stringify(status);\n const error = succeeded\n ? null\n : status === null\n ? `The batch of step \"${key}\" (${cached.batchId}) no longer exists.`\n : `The batch of step \"${key}\" failed: ${status.failed} failed and ` +\n `${status.cancelled} cancelled of ${status.total}.`;\n const record = await this.write(key, ({ step, now }) => {\n const next = this.record(key, step, {\n status: succeeded ? \"completed\" : \"failed\",\n output,\n error,\n finishedAt: now,\n });\n return { result: next, step: next };\n });\n if (!succeeded) throw failure(key, record);\n return status!;\n }\n}\n\n/** The error a failed step throws, on the pass it failed and every later one. */\nfunction failure(key: string, step: StepRecord): StepFailedError {\n const batch = step.batchId !== null && step.output !== null\n ? (JSON.parse(step.output) as BatchStatus)\n : undefined;\n return new StepFailedError(\n key,\n batch ? (step.error ?? `Step \"${key}\" failed.`) : `Step \"${key}\" failed: ${step.error ?? \"unknown error\"}`,\n batch,\n );\n}\n\n/**\n * A value as stored: JSON, or `null` for `undefined`. Refused past\n * `WORKFLOW_OUTPUT_LIMIT`, and for what JSON cannot carry.\n */\nexport function encode(value: unknown, what: string): string | null {\n if (value === undefined) return null;\n const json = JSON.stringify(value);\n if (json === undefined) {\n throw new TypeError(`${what} cannot be stored: JSON has no form for it.`);\n }\n const bytes = Buffer.byteLength(json, \"utf8\");\n if (bytes > WORKFLOW_OUTPUT_LIMIT) {\n throw new RangeError(\n `${what} is ${bytes} bytes as JSON, over the ${WORKFLOW_OUTPUT_LIMIT}-byte ` +\n `limit. Store it elsewhere and return its id.`,\n );\n }\n return json;\n}\n\nexport function decode(output: string | null): unknown {\n return output === null ? undefined : JSON.parse(output);\n}\n\nexport function describe(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n",
|
|
17
16
|
"import { AsyncResource } from \"node:async_hooks\";\nimport { isMainThread } from \"node:worker_threads\";\n\nimport type { Application } from \"../../foundation/Application\";\nimport { DatabaseManager } from \"../../database/DatabaseManager\";\nimport { kernelContext } from \"../../kernel/context\";\nimport { deferUntilCommit } from \"../../orm/context\";\nimport { isShuttingDown } from \"../../server/shutdown\";\nimport { DatabaseLockStore } from \"../lock/DatabaseLockStore\";\nimport { type HeldLock, LockManager } from \"../lock/LockManager\";\nimport type { LockStore } from \"../lock/LockStore\";\nimport { MemoryLockStore } from \"../lock/MemoryLockStore\";\nimport { DatabaseQueueDriver } from \"./DatabaseQueueDriver\";\nimport { Job } from \"./Job\";\nimport { queueConfigDefaults, type QueueConfig } from \"./config\";\nimport { MemoryQueueDriver } from \"./MemoryQueueDriver\";\nimport type { ClaimOptions, ClaimedJob, EnqueueBatch, QueueDriver } from \"./QueueDriver\";\nimport type { BatchCallbacks, BatchStatus, JobCall } from \"./batch\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { backoffFor } from \"./backoff\";\nimport type { WorkflowClass } from \"./workflow/Workflow\";\nimport { WorkflowRuntime } from \"./workflow/WorkflowRuntime\";\n\nexport { backoffFor };\n\n/**\n * The thread a `worker = true` job runs in.\n *\n * The `await` on `dispatchJob` is load-bearing and its absence was a hang.\n * `postMessage` structured-clones its argument and a Promise is not cloneable,\n * so an un-awaited `dispatchJob` posted the pending promise, threw\n * `DataCloneError` inside this handler, and posted nothing at all. `runInWorker`\n * then never settled: `run` below never returned, its concurrency slot was\n * never decremented, and neither the retry path nor `onDeadletter` ever fired —\n * after `concurrency` such jobs the queue sits at its limit forever, with no\n * error anywhere. Any job whose `run` is `async` hit it, which is every job\n * that touches IO; a queued listener hits it unconditionally, because the\n * synthetic job's `run` awaits `handle`.\n *\n * The await earns two more things. A rejecting job now reaches the `catch` and\n * comes back as `{error}`, where the queue's ordinary retry-then-dead-letter\n * path can have it, instead of being lost with the promise. And `destroy()` now\n * runs after the job rather than under it, so the cloned kernel — its database\n * connections included — outlives the work it was cloned for.\n */\nfunction createWorker() {\n const APP_DIR = process.env.APP_DIR;\n const ROOT_DIR = process.env.ROOT_DIR;\n\n const appPath =\n process.env.NODE_ENV === \"production\"\n ? `${ROOT_DIR}/dist/server/bootstrap.mjs`\n : `${APP_DIR}/bootstrap.ts`;\n\n const file = new File(\n [\n `\n import { app } from \"${appPath}\"\n self.onmessage = async (event) => {\n const clone = app.clone()\n let result = null;\n let error = null;\n try {\n result = await clone.dispatchJob(event.data.jobName, event.data.args)\n } catch (err) {\n error = err\n }\n clone.destroy()\n if(error) {\n self.postMessage({error});\n } else {\n self.postMessage({result});\n }\n };\n `,\n ],\n \"worker.ts\",\n );\n const url = URL.createObjectURL(file);\n return new Worker(url);\n}\n\n// TODO: terminate worker after the job is done\nasync function runInWorker(jobName: string, args: string) {\n const worker = createWorker();\n worker.postMessage({ jobName, args });\n return await new Promise((resolve, reject) => {\n worker.onmessage = (e) => {\n const data = e.data;\n if (\"error\" in data) {\n reject(data.error);\n } else {\n resolve(data.result);\n }\n };\n });\n}\n\n/**\n * The async context every job runs in: the one this module was evaluated in,\n * which is boot, outside any request.\n *\n * The worker loop is long-lived and started lazily, by the first dispatch, and\n * an async function keeps the context it was started in across every `await`.\n * Started from a request, it would run every later job — dispatched by any\n * request at all — inside the first one's `RequestContext`, and with its ORM\n * transaction handle if it had one open: one user's identity leaking into\n * another's work. Captured here, where no request exists, and entered by `start()`, a job\n * sees no request at all; the Application is entered separately, per job.\n */\nconst bootScope = new AsyncResource(\"gemi.queue\");\n\n/**\n * The longest the loop waits between retries while `claim` keeps rejecting.\n *\n * Long enough that a database which is properly down is not asked once a\n * second by every worker process for as long as it stays down, short enough\n * that the queue is claiming again within a minute of it coming back.\n */\nconst maxClaimBackoff = 60_000;\n\ndeclare global {\n /**\n * The queue loop a `gemi dev` server is running over a driver that outlives\n * the process, kept where a `bun --hot` reload cannot lose it. A reload\n * re-evaluates every module and boots a new application, but the previous\n * application's loop is a live closure and keeps claiming — from the same\n * table, with the code it was loaded with. This is how the next\n * application finds it to stop it; see `startClaimingIfServing`.\n *\n * Typed by what is called on it, not as `QueueManager`: after a reload the\n * one held here is an instance of the previous module graph's class.\n */\n var __gemiDevQueue: { stop(): Promise<unknown> } | undefined;\n}\n\n/** What `Job.dispatchBatch` resolves to. */\nexport type DispatchedBatch = {\n /** The batch's id, for `Job.findBatch` and `Job.cancelBatch`. */\n id: string;\n /** How many jobs it was dispatched with. */\n total: number;\n};\n\n/** The options of `Job.dispatchBatch`. */\nexport type JobBatchOptions = {\n /** A label kept with the batch, for finding it in storage and in its status. */\n name?: string;\n /**\n * Whether a dead-lettered job leaves the rest running. Default `false`: the\n * first one cancels the batch.\n */\n allowFailures?: boolean;\n /**\n * Enqueued once every job has ended, when the batch was not cancelled and\n * no job failed (or `allowFailures` is set). Build it with `Job.with(...)`.\n */\n then?: JobCall;\n /** Enqueued at the first failed job, or at `cancelBatch`, whichever is first. */\n catch?: JobCall;\n /** Enqueued once every job has ended, whatever happened. */\n finally?: JobCall;\n};\n\n/** What `drain` could not wait out. */\nexport type DrainResult = {\n /**\n * Jobs still running when the timeout elapsed. They keep running, and keep\n * their leases, until they settle or the process exits; with a driver that\n * outlives the process, an exit leaves them to be reclaimed once their lease\n * runs out. Waiting jobs are not listed — they were never taken, and are\n * wherever the driver keeps them.\n */\n unfinished: ClaimedJob[];\n};\n\nexport class QueueManager {\n static token = \"queue\";\n\n jobs: Record<string, new () => Job> = {};\n\n readonly config: Required<QueueConfig>;\n readonly driver: QueueDriver;\n\n private readonly application: Application | undefined;\n /**\n * Keyed by claim, `id:attempt`, not by job id. A lease that lapses while\n * its job is still running here — heartbeats failing through a database\n * blip, or an event loop blocked past the visibility timeout — lets this\n * same process claim the job again. Both runs are then really running, so\n * both take a slot. Keyed by id alone, the second claim overwrote the first\n * and the first one's `finally` then deleted it: the live run stopped being\n * counted, drained or heartbeated, so its lease lapsed in turn and the job\n * was claimed again into a slot that was never free.\n */\n private readonly inFlight = new Map<\n string,\n { job: ClaimedJob; done: Promise<void> }\n >();\n private state: \"idle\" | \"running\" | \"stopped\" = \"idle\";\n private looping = false;\n private claiming: Promise<unknown> | undefined;\n private woken = false;\n /** Consecutive `claim` rejections; see `sleep`. Cleared by a claim that returns. */\n private claimFailures = 0;\n private resume: (() => void) | undefined;\n private unsubscribe: (() => void) | undefined;\n private heartbeatTimer: ReturnType<typeof setInterval> | undefined;\n /** Unknown names already reported as left for another replica; see `run`. */\n private readonly releasedNames = new Set<string>();\n private lockManager: LockManager | undefined;\n private workflowRuntime: WorkflowRuntime | undefined;\n\n /**\n * `application` is entered around every job, so `app()` inside one resolves\n * to it rather than to whichever application happens to be the static\n * fallback. The provider always passes it; a manager built bare, as the unit\n * tests do, runs jobs with no application entered.\n */\n constructor(\n config: QueueConfig = {},\n options: { application?: Application } = {},\n ) {\n this.config = withDefaults(queueConfigDefaults(), config);\n this.application = options.application;\n this.driver = resolveDriver(this.config.driver, this.application);\n this.useJobs(this.config.jobs);\n if (this.config.workflows.length > 0) this.useWorkflows(this.config.workflows);\n }\n\n /**\n * Replaces the registered set, for the provider to hand over what it found\n * under `app/jobs`.\n *\n * This exists because the two phases disagree about when the answer is\n * knowable. The manager is constructed in `register()`, which is synchronous\n * and must resolve nothing; reading a directory and importing what is in it is\n * neither. So the manager is built from whatever the config slice declared —\n * nothing, when the app left `jobs` out — and the discovered set arrives in\n * `boot()`.\n *\n * The consequence worth knowing: anything that constructs an application and\n * skips phase two sees an empty registry, and every dispatch against an empty\n * registry is dropped — loudly on stderr, but after `Job.dispatch` has already\n * returned, so no caller finds out. On a durable driver not even that is\n * immediate: the job is left for another replica, and the stderr line comes\n * only once `unknownJobGrace` has passed. An app that lists its jobs explicitly is\n * unaffected, because that list is already in place by the end of `register()`.\n */\n useJobs(jobs: Array<new () => Job>) {\n this.config.jobs = jobs;\n\n // Built one at a time rather than by `Object.fromEntries`, which resolves a\n // repeated key by keeping the last and saying nothing.\n //\n // Two classes with one name is the worst failure in this subsystem, and it\n // is worse than the dropped dispatch the rest of this file is about: the\n // registry is keyed by class name, a dispatch carries a class name, so\n // `SendEmail.dispatch(...)` on the one under `app/jobs/auth` would run the\n // body of the one under `app/jobs/billing`. Nothing is dropped and nothing\n // errors — the wrong work happens and reports success.\n //\n // Discovery is what makes it ordinary. A hand-written list forces an import\n // alias in one visible file the moment two names clash; a directory walk\n // does not, and `auth/SendEmail.ts` beside `billing/SendEmail.ts` is a\n // perfectly natural thing to write. So the first claim wins and the second\n // is refused out loud — the same rule `Scheduler.start` applies to a cron\n // name, and the reverse of the silent last-wins this replaces.\n this.jobs = {};\n for (const job of jobs) {\n this.claim(job);\n }\n this.registerTickJob();\n }\n\n /**\n * Replaces the registered workflows, for the provider to hand over what it\n * found under `app/workflows`. With at least one, the internal job their\n * passes run in is registered too. See `Workflow`.\n */\n useWorkflows(workflows: WorkflowClass[]) {\n this.config.workflows = workflows;\n this.workflows.use(workflows);\n this.registerTickJob();\n }\n\n /** The registered workflow classes, as handed over. */\n get registeredWorkflows(): ReadonlyArray<WorkflowClass> {\n return [...this.config.workflows];\n }\n\n /**\n * Workflows (#846) over this queue's driver: what `Workflow.start`,\n * `signal`, `find` and `cancel` call.\n */\n get workflows(): WorkflowRuntime {\n this.workflowRuntime ??= new WorkflowRuntime(this);\n return this.workflowRuntime;\n }\n\n /**\n * The tick job, beside the app's own, once there is a workflow to tick.\n * Not in `registeredJobs`, which reports what the app handed over.\n */\n private registerTickJob() {\n if (!this.workflowRuntime || Object.keys(this.workflowRuntime.workflows).length === 0) return;\n const tick = this.workflowRuntime.tickJob;\n if (this.jobs[tick.name] && this.jobs[tick.name] !== tick) {\n console.error(\n `A queued job is named \"${tick.name}\", which the workflow runtime uses. ` +\n `Workflows will not run until it is renamed.`,\n );\n return;\n }\n this.jobs[tick.name] = tick;\n }\n\n /**\n * Registers one more job beside whatever `useJobs` already took.\n *\n * This exists for the queued-listener adapter, which registers a synthetic\n * job per queued listener from `EventServiceProvider.boot()` — after the\n * queue's own `boot()` has filled the registry. `useJobs` cannot serve that\n * caller: it *replaces* the registry, so a second call would discard every\n * job the app wrote and leave the queue holding listeners alone. Reading\n * `registeredJobs` back, concatenating and calling `useJobs` again avoids\n * that and is still the wrong shape — it re-runs the collision check over\n * jobs that already passed it, so a duplicate the author has already been\n * told about is reported a second time on every boot.\n *\n * Same rule as `useJobs`, deliberately: the first claim on a name wins and\n * the second is refused out loud. And recorded in `config.jobs` either way,\n * so `registeredJobs` keeps reporting everything the manager was handed\n * rather than what it accepted — a refused job is visible to a test there.\n *\n * A new array rather than a `push`, because `useJobs` keeps the caller's\n * array by reference and appending to it would edit the config slice or the\n * discovered list under whoever else is holding it.\n */\n registerJob(job: new () => Job) {\n this.config.jobs = [...this.config.jobs, job];\n this.claim(job);\n }\n\n /**\n * Puts one job in the registry, or refuses it because the name is taken.\n *\n * The rule and the reason are in `useJobs` above; this is only the shape both\n * entry points share, so that a job arriving one at a time cannot be admitted\n * on terms the batch would have refused.\n */\n private claim(job: new () => Job) {\n if (this.jobs[job.name]) {\n console.error(\n `Two queued jobs are named \"${job.name}\" — the first is registered ` +\n `and this one is not, so dispatching either would have run one of ` +\n `them. A class name is the queue's key, so only one job can hold ` +\n `it. Rename one.`,\n );\n return;\n }\n this.jobs[job.name] = job;\n }\n\n /**\n * What the manager was handed, discovered or declared.\n *\n * The registry is keyed by name, and a name is exactly what a dispatch\n * carries, so \"is this job registered?\" is a question with a silent wrong\n * answer — `run()` drops an unknown name long after the caller moved on.\n * This is where a test asks it out loud.\n *\n * It reports what came in, not what the registry accepted, so a name claimed\n * twice appears twice here — deliberately, the same way `Scheduler.jobs`\n * does. A test walking this should see the collision rather than have it\n * tidied away. A copy, so that walk cannot edit the registry underneath it.\n */\n get registeredJobs(): ReadonlyArray<new () => Job> {\n return [...this.config.jobs];\n }\n\n dispatchJob(jobName: string, args: string) {\n if (this.jobs[jobName]) {\n const job = new this.jobs[jobName]();\n return job.run(JSON.parse(args));\n }\n }\n\n /**\n * Queues a job and resolves to its id once the driver has recorded it, then\n * makes sure the worker loop is running — unless `drain` stopped it, in which\n * case the job waits in the driver for whichever process claims next. With\n * the memory driver that is nobody; see `drain`. A durable driver's job also\n * waits there when this process does not claim: it is not a server, or it is\n * one started with `GEMI_QUEUE_CLAIM=off`; see `claimsInThisProcess`.\n *\n * Inside an open ORM transaction the job belongs to the transaction. A\n * driver that can write it on the transaction does (`joinsTransaction`);\n * for any other, it is held and recorded once the transaction commits, and\n * never if it rolls back. Either way no claimer can see the job before the\n * data it was dispatched about exists. A held dispatch resolves at once, to\n * the id the job will be recorded under: the transaction does not commit\n * until its callback returns, so a caller awaiting a promise that waited for\n * the commit would never return.\n */\n push(\n job: new () => Job,\n args: string,\n options: {\n /**\n * Whether a driver that cannot record the job is reported from here.\n * On by default, because the usual caller is a fire-and-forget\n * `Job.dispatch(...)` whose promise nobody reads. A caller with\n * something better to say — `EventManager`, which knows the event and\n * the listener — turns it off and says that instead. A held dispatch is\n * reported here whatever this says, because its promise has already\n * resolved and the caller has nothing left to catch.\n */\n reportFailure?: boolean;\n } = {},\n ): Promise<string> {\n // A unique job takes its key before it is recorded; see `pushUnique`.\n // Computed here so a `uniqueId` that throws does so on the caller's stack.\n const unique = this.uniqueKey(job, args);\n if (unique) return this.pushUnique(job, args, unique, options);\n\n // Asked before anything is written, and in the caller's async context,\n // which is where the transaction is. The held branch is the fallback\n // rather than the rule because it loses the job to a crash between the\n // commit and the enqueue; written on the transaction, the job commits\n // with the rows or not at all.\n const joins = this.driver.joinsTransaction?.() === true;\n if (!joins) {\n // `deferUntilCommit` is the ORM's commit hook, and the same one an\n // `afterCommit` event waits on: a savepoint that rolls back takes its\n // held dispatches with it, and the callback runs outside the\n // transaction, so the enqueue cannot be pulled back into it.\n const id = Bun.randomUUIDv7();\n const held = deferUntilCommit(() =>\n // Awaited, so the transaction's own promise waits for the enqueue and\n // a script that exits after its last transaction does not exit under\n // it. The rejection is swallowed only because `record` has already\n // reported it; rethrown, the drain would report it a second time.\n this.record(job, args, {\n id,\n reportFailure: true,\n committed: true,\n }).then(\n () => {},\n () => {},\n ),\n );\n if (held) return Promise.resolve(id);\n }\n return this.record(job, args, {\n reportFailure: options.reportFailure,\n joins,\n });\n }\n\n /**\n * Queues a batch: every job, the batch and its callbacks in one atomic\n * write. See `Job.dispatchBatch`.\n *\n * Inside an ORM transaction the batch belongs to it, exactly as a single\n * dispatch does in `push`: written on it by a driver that joins, otherwise\n * held and recorded at the commit, resolving at once to the id it will have.\n */\n pushBatch(\n job: new () => Job,\n args: string[],\n options: JobBatchOptions = {},\n ): Promise<DispatchedBatch> {\n const batch = this.buildBatch(job, args, options);\n const dispatched: DispatchedBatch = { id: batch.id, total: args.length };\n\n const joins = this.driver.joinsTransaction?.() === true;\n if (!joins) {\n const held = deferUntilCommit(() =>\n this.recordBatch(batch, { committed: true }).then(\n () => {},\n () => {},\n ),\n );\n if (held) return Promise.resolve(dispatched);\n }\n return this.recordBatch(batch, { joins }).then(() => dispatched);\n }\n\n /**\n * @internal The batch `pushBatch` records, checked: for `pushBatch` and for\n * a workflow's `step.batch`, which records it in a write of its own. Throws\n * on the caller's stack for a driver without batches, a worker job, a\n * unique job and a callback that is not a job call.\n */\n buildBatch(job: new () => Job, args: string[], options: JobBatchOptions = {}): EnqueueBatch {\n if (!this.driver.enqueueBatch) {\n throw new Error(\n `This queue's driver does not support batches. The memory and ` +\n `database drivers do.`,\n );\n }\n const instance = new job();\n if (instance.worker) {\n throw new Error(\n `${job.name} is a worker job, and a worker job cannot be dispatched ` +\n `in a batch: its thread has no way to report progress or reach the ` +\n `batch.`,\n );\n }\n if (job.prototype.uniqueId !== Job.prototype.uniqueId) {\n throw new Error(\n `${job.name} is unique (it defines uniqueId), and a unique job cannot ` +\n `be dispatched in a batch: a duplicate would resolve to a job outside ` +\n `the batch, and the batch would wait for it forever.`,\n );\n }\n\n const callbacks: BatchCallbacks = {};\n for (const key of [\"then\", \"catch\", \"finally\"] as const) {\n const call = options[key];\n if (call === undefined) continue;\n if (typeof call?.name !== \"string\" || !Array.isArray(call.args)) {\n throw new Error(\n `The batch's ${key} callback is not a job call. Build it with ` +\n `SomeJob.with(...args).`,\n );\n }\n callbacks[key] = { name: call.name, args: call.args };\n }\n\n return {\n id: Bun.randomUUIDv7(),\n name: options.name ?? null,\n job: job.name,\n args,\n allowFailures: options.allowFailures === true,\n callbacks,\n };\n }\n\n /** `pushBatch`, once it is known that the batch is recorded now; see `record`. */\n private recordBatch(\n batch: EnqueueBatch,\n options: { joins?: boolean; committed?: boolean },\n ): Promise<void> {\n const written = this.driver.enqueueBatch!(batch);\n this.startIfIdle();\n const wake = () => !this.driver.subscribe && this.state === \"running\" && this.wake();\n const wakeAtCommit = options.joins === true && deferUntilCommit(wake);\n written.then(\n () => wakeAtCommit || wake(),\n (error: unknown) => {\n // Only a held batch is reported here: its caller's promise resolved\n // inside the transaction, so it has nothing left to catch. Every\n // other caller awaits the rejection, as it needs the batch's id.\n if (!options.committed) return;\n console.error(\n `[gemi] The queue driver could not record a batch of ${batch.job}, ` +\n `which was held until its transaction committed. The transaction ` +\n `stays committed; the batch's jobs did not run and will not be ` +\n `retried.`,\n error,\n );\n },\n );\n return written;\n }\n\n /** The batch's status, or `null` for an unknown id. See `Job.findBatch`. */\n async findBatch(id: string): Promise<BatchStatus | null> {\n if (!this.driver.findBatch) {\n throw new Error(`This queue's driver does not support batches.`);\n }\n return this.driver.findBatch(id);\n }\n\n /**\n * Cancels a running batch, and resolves to whether it did. See\n * `Job.cancelBatch`.\n */\n async cancelBatch(id: string): Promise<boolean> {\n if (!this.driver.cancelBatch) {\n throw new Error(`This queue's driver does not support batches.`);\n }\n const cancelled = await this.driver.cancelBatch(id);\n // Cancelling can make `catch` and `finally` due.\n if (cancelled) this.claimSoon();\n return cancelled;\n }\n\n /**\n * The locks unique jobs, cron jobs' `withoutOverlapping` and `onOneServer`,\n * and the `Lock` facade use, over the store the `locks` setting names. Built\n * on first use, so an app that uses none of them never touches the store.\n */\n get locks(): LockManager {\n this.lockManager ??= new LockManager(this.resolveLockStore());\n return this.lockManager;\n }\n\n private resolveLockStore(): LockStore {\n const locks = this.config.locks;\n if (locks === \"auto\") {\n const store = this.driver.lockStore?.();\n if (store) return store;\n if (this.durable) {\n console.warn(\n `[gemi] The queue driver keeps no locks, so unique jobs, ` +\n `withoutOverlapping and onOneServer only hold within this process. ` +\n `Set the queue slice's \\`locks\\` to \"database\" or a LockStore.`,\n );\n }\n return new MemoryLockStore();\n }\n if (locks === \"memory\") return new MemoryLockStore();\n if (locks === \"database\" || typeof locks === \"function\") {\n if (!this.application && (locks === \"database\" || locks.length > 0)) {\n throw new Error(\n `The queue's locks need the application they belong to, and this ` +\n `QueueManager was built without one. Pass { application }.`,\n );\n }\n if (locks === \"database\") {\n return new DatabaseLockStore(this.application!.make(DatabaseManager));\n }\n return locks(this.application!);\n }\n if (typeof locks === \"string\") {\n throw new Error(\n `Unknown queue locks \"${locks}\". The queue slice's locks is \"auto\", ` +\n `\"memory\", \"database\", a LockStore, or a function returning one.`,\n );\n }\n return locks;\n }\n\n /**\n * The lock key a dispatch of a unique job takes, or `undefined` for a job\n * that does not declare `uniqueId` or a dispatch it returned nothing for.\n */\n private uniqueKey(job: new () => Job, args: string) {\n if (job.prototype.uniqueId === Job.prototype.uniqueId) return undefined;\n const instance = new job();\n const id = instance.uniqueId(...(JSON.parse(args) as unknown[]));\n if (id === undefined || id === null || id === \"\") return undefined;\n return { key: uniqueLockName(job.name, id), ttl: Math.max(1, instance.uniqueFor) };\n }\n\n /**\n * Records a unique job if its key is free, and otherwise resolves to the id\n * of the job holding it. The key's lock is owned by the job's id, which is\n * how the job frees it when it ends and how a duplicate finds it.\n *\n * Inside a transaction the whole dispatch waits for the commit, even on a\n * driver that could join the transaction. The key is taken outside it, so\n * written on the transaction the job could roll back and leave its key held\n * for `uniqueFor` with nothing queued under it. A held dispatch resolves to\n * the id the job will have, and is dropped at the commit if a job with the\n * same key is queued by then.\n */\n private pushUnique(\n job: new () => Job,\n args: string,\n unique: { key: string; ttl: number },\n options: { reportFailure?: boolean },\n ): Promise<string> {\n const id = Bun.randomUUIDv7();\n const held = deferUntilCommit(() =>\n this.recordUnique(job, args, unique, id, { report: true, committed: true }).then(\n () => {},\n () => {},\n ),\n );\n if (held) return Promise.resolve(id);\n return this.recordUnique(job, args, unique, id, {\n report: options.reportFailure !== false,\n committed: false,\n });\n }\n\n private recordUnique(\n job: new () => Job,\n args: string,\n unique: { key: string; ttl: number },\n id: string,\n options: { report: boolean; committed: boolean },\n ): Promise<string> {\n const store = this.locks.store;\n const recorded = (async () => {\n // A few rounds, for a key freed between a refused `acquire` and the\n // `holder` read that follows it.\n for (let round = 0; round < 5; round++) {\n if ((await store.acquire(unique.key, id, unique.ttl)) !== null) {\n try {\n return await this.record(job, args, { id, reportFailure: false });\n } catch (error) {\n await store.release(unique.key, id).catch(() => {});\n throw error;\n }\n }\n const holder = await store.holder(unique.key);\n if (holder) return holder.owner;\n }\n throw new Error(\n `The unique key \"${unique.key}\" kept changing hands, so ${job.name} ` +\n `was not queued.`,\n );\n })();\n recorded.catch((error: unknown) => {\n if (!options.report) return;\n console.error(\n `[gemi] The queue could not record the unique job ${job.name}` +\n (options.committed\n ? `, which was held until its transaction committed. The ` +\n `transaction stays committed; the job did not run and will ` +\n `not be retried.`\n : `, so it did not run and will not be retried.`),\n error,\n );\n });\n return recorded;\n }\n\n /**\n * Frees a unique job's key once the job has ended for good: completed or\n * dead-lettered. Released by the job's id, so a key a newer dispatch holds\n * after `uniqueFor` ran out is left alone.\n */\n private async releaseUnique(job: Job, args: unknown[], claimed: ClaimedJob) {\n if (job.uniqueId === Job.prototype.uniqueId) return;\n try {\n const id = job.uniqueId(...args);\n if (id === undefined || id === null || id === \"\") return;\n await this.locks.store.release(uniqueLockName(claimed.name, id), claimed.id);\n } catch (error) {\n console.error(\n `[gemi] Could not free the unique key of ${claimed.name} (${claimed.id}); ` +\n `it frees itself after uniqueFor.`,\n error,\n );\n }\n }\n\n /** `push`, once it is known that the job is recorded now. */\n private record(\n job: new () => Job,\n args: string,\n options: {\n id?: string;\n reportFailure?: boolean;\n /** Written on the caller's open transaction; see `push`. */\n joins?: boolean;\n /** Held until a transaction committed; changes only the error line. */\n committed?: boolean;\n },\n ): Promise<string> {\n const id = this.driver.enqueue({\n name: job.name,\n args,\n ...(options.id === undefined ? {} : { id: options.id }),\n });\n // A driver that outlives the process is shared with every other one, so\n // a script or console command that dispatches would otherwise claim up to\n // `concurrency` of the table's jobs — other replicas' included — and exit\n // under them, costing each an attempt and a lease's wait. There the job\n // waits in the driver for a server or a worker. A manager built by hand,\n // with no application, is its caller's to run and keeps starting.\n this.startIfIdle();\n // A driver without `subscribe` is only polled, so without the wake a job\n // dispatched here would wait up to `pollInterval` in a queue with room.\n // A spurious wake just claims nothing.\n //\n // A job written on the caller's transaction is not claimable until that\n // commits, so its wake waits for the commit too — woken now, the loop\n // would claim nothing and then sleep a whole `pollInterval` past it.\n // Registered here, synchronously, because the commit hook is found\n // through the caller's async context, and this is the one place that is\n // certainly still current.\n const wake = () =>\n !this.driver.subscribe && this.state === \"running\" && this.wake();\n const wakeAtCommit = options.joins === true && deferUntilCommit(wake);\n\n // The rejection is reported here unless the caller says it will do it\n // itself, and whatever the driver is. It used to depend on both, and was\n // lost either way: a polled driver got an empty rejection arm, which marks\n // `id` handled — and `id` is what `push` returns — so a fire-and-forget\n // `SendReceiptJob.dispatch(...)` whose INSERT failed (a failover, a pool\n // timeout, a table not migrated yet) produced no unhandled rejection and\n // no line anywhere, and the job simply never ran. A subscribing driver got\n // no arm at all, so the same failure surfaced as a bare unhandled\n // rejection. A caller that awaits still gets the rejection either way and\n // can still decide what to do about it.\n id.then(\n () => wakeAtCommit || wake(),\n (error: unknown) => {\n if (options.reportFailure === false) return;\n console.error(\n `[gemi] The queue driver could not record ${job.name}` +\n (options.committed\n ? `, which was held until its transaction committed. The ` +\n `transaction stays committed; the job did not run and will ` +\n `not be retried.`\n : `, so it did not run and will not be retried.`),\n error,\n );\n },\n );\n return id;\n }\n\n /**\n * Runs a dead-lettered job again, from attempt 1 with its whole\n * `maxAttempts`, and resolves to whether a dead job was found under `id`.\n * `false` for an id that is waiting, running, finished or unknown: only a\n * dead job is brought back, so this cannot restart one that is running\n * somewhere.\n *\n * The job is claimed the way a dispatch's is. On a server it is run here as\n * soon as there is room; from a console command it waits in the driver for\n * a server or a worker, which with a polling driver means up to\n * `pollInterval`.\n *\n * Refused for a driver without `retryDead`. The memory driver keeps nothing\n * of a dead job, so there is no id it could bring back, and resolving\n * `false` would read as \"no such job\" to someone holding an id they just saw\n * in a log.\n */\n async retryDead(id: string): Promise<boolean> {\n if (!this.driver.retryDead) {\n throw new Error(\n `This queue's driver keeps nothing of a dead-lettered job, so there ` +\n `is nothing to retry. The database driver keeps them.`,\n );\n }\n const found = await this.driver.retryDead(id);\n if (found) this.claimSoon();\n return found;\n }\n\n /**\n * Starts the loop unless `drain` stopped it or this process should leave a\n * shared driver's jobs to a server — the rule `push` explains.\n */\n private startIfIdle() {\n if (this.state === \"idle\" && (!this.durable || this.mayClaimHere())) {\n this.start();\n }\n }\n\n /**\n * For a job the driver has just made claimable: start the loop, or wake a\n * running one that only polls, as `push` does for a dispatch.\n */\n /** @internal */\n claimSoon() {\n this.startIfIdle();\n if (!this.driver.subscribe && this.state === \"running\") this.wake();\n }\n\n /**\n * Starts claiming. Idempotent, and called by the first `push`, so an app\n * does not need to; it is public for a process that should run jobs it\n * never dispatched — ones a driver kept across a restart — and for resuming\n * after `drain`.\n */\n start() {\n if (this.state === \"running\") return;\n this.state = \"running\";\n // Only a development server's loop over a shared driver: a memory queue\n // is only ever fed by its own application, and a hand-built manager or a\n // test's is its caller's to stop.\n if (this.durable && this.application && this.mayClaimHere() && !isProduction()) {\n globalThis.__gemiDevQueue = this;\n }\n this.unsubscribe = this.driver.subscribe?.(() => this.wake());\n // A loop a `drain` has not yet seen off picks the new state up itself;\n // starting a second would claim twice per wake.\n if (this.looping) return this.wake();\n bootScope.runInAsyncScope(() => void this.loop());\n }\n\n /**\n * Stops claiming, waits up to `timeoutMs` for the jobs already running, and\n * reports the ones that did not finish.\n *\n * Nothing is cancelled — a job has no way to be told — so an unfinished job\n * keeps running after this resolves. What happens to it then is the\n * driver's: the memory driver loses it with the process, along with every\n * job still waiting; one that outlives the process lets another claim it\n * once the lease runs out.\n *\n * A later `push` records its job but does not restart the loop. `start()`\n * does.\n */\n async drain(timeoutMs = Infinity): Promise<DrainResult> {\n this.state = \"stopped\";\n if (globalThis.__gemiDevQueue === this) globalThis.__gemiDevQueue = undefined;\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n this.wake();\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<void>((resolve) => {\n if (timeoutMs !== Infinity) timer = setTimeout(resolve, timeoutMs);\n });\n // The claim in progress first, because what it returns is run: those jobs\n // are leased to this process already, and handing them back would cost\n // each of them an attempt it never made.\n const settled = (async () => {\n await this.claiming?.catch(() => {});\n await Promise.allSettled([...this.inFlight.values()].map((e) => e.done));\n })();\n await Promise.race([settled, deadline]);\n clearTimeout(timer);\n\n return {\n unfinished: [...this.inFlight.values()].map((e) => ({ ...e.job })),\n };\n }\n\n /** `drain(0)`: stop claiming, and report what is running without waiting. */\n stop(): Promise<DrainResult> {\n return this.drain(0);\n }\n\n /** How many jobs this process is running right now. */\n get running(): number {\n return this.inFlight.size;\n }\n\n /**\n * Claims while there is room, runs what it claims, and otherwise sleeps\n * until something changes: a job finishing frees a slot, or the driver's\n * `subscribe` says there is work. A driver without `subscribe` is polled\n * every `pollInterval` instead. This replaces a one-second timer that\n * spun while the queue was full.\n *\n * `woken` records a wake that arrived while a claim was in flight, when\n * there was nothing yet to resume; without it that job would wait for the\n * next unrelated wake.\n */\n private async loop() {\n this.looping = true;\n try {\n await this.claimWhileRunning();\n } finally {\n this.looping = false;\n }\n }\n\n private async claimWhileRunning() {\n while (this.state === \"running\") {\n // Once the server has been told to stop, a driver that outlives the\n // process gets nothing new taken from it: a job claimed now would likely\n // be cut off by the exit, and cost an attempt and a lease's wait, when\n // another replica can run it instead. The memory driver keeps claiming\n // until the provider's `drain()` stops it, because nobody else can run\n // its jobs — one waiting at the signal, or dispatched by a request\n // still draining, is run here or not at all.\n const room = this.durable && isShuttingDown()\n ? 0\n : this.config.concurrency - this.inFlight.size;\n\n if (room > 0) {\n this.woken = false;\n const claim = this.driver.claim(room, {\n ...this.lease(),\n registered: {\n names: Object.keys(this.jobs),\n graceMs: this.config.unknownJobGrace,\n },\n });\n this.claiming = claim;\n let claimed: ClaimedJob[] = [];\n try {\n claimed = await claim;\n this.claimFailures = 0;\n } catch (error) {\n this.claimFailures++;\n console.error(\n `The queue could not claim jobs from its driver; it will try ` +\n `again in ${this.retryDelay()}ms.`,\n error,\n );\n } finally {\n this.claiming = undefined;\n }\n for (const job of claimed) this.execute(job);\n\n // A full batch may have left more behind; the next pass either claims\n // it or, with no room left, sleeps until a slot frees.\n if (claimed.length === room) continue;\n if (this.woken && this.inFlight.size < this.config.concurrency) {\n continue;\n }\n }\n\n await this.sleep();\n }\n }\n\n /**\n * Waits for the next thing worth waking for: a slot freeing, a `subscribe`\n * driver saying there is work, or the poll timer a driver without\n * `subscribe` gets.\n *\n * A claim that rejected arms a timer whatever the driver does, and that is\n * the whole reason this is not just the `subscribe` test. The wake that\n * prompted the lost claim has already been consumed, so a driver that only\n * speaks up on an enqueue — LISTEN/NOTIFY, say — has nothing left to\n * announce: an idle worker whose one claim died on a connection reset would\n * sit there, with every job already waiting, until some unrelated process\n * enqueued again. On a busy worker an in-flight job's `wake` covers it; an\n * idle one has nothing to be rescued by.\n *\n * The delay doubles per consecutive failure so that storage which is\n * properly down is not asked once a `pollInterval` for as long as it stays\n * down, and the first claim that returns clears the count.\n */\n private sleep() {\n return new Promise<void>((resolve) => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const delay = this.claimFailures > 0\n ? this.retryDelay()\n : this.driver.subscribe\n ? undefined\n : this.config.pollInterval;\n if (delay !== undefined) {\n // Unref'd: a polling queue alone should not hold the process open.\n timer = setTimeout(() => this.wake(), delay);\n timer.unref?.();\n }\n this.resume = () => {\n clearTimeout(timer);\n resolve();\n };\n });\n }\n\n /** `pollInterval`, doubled once per consecutive claim failure, capped. */\n private retryDelay() {\n const doublings = Math.min(Math.max(0, this.claimFailures - 1), 30);\n return Math.min(this.config.pollInterval * 2 ** doublings, maxClaimBackoff);\n }\n\n private wake() {\n this.woken = true;\n const resume = this.resume;\n this.resume = undefined;\n resume?.();\n }\n\n /**\n * Whether the driver keeps jobs past this process: anything but memory.\n * Only such a queue can be fed by one process and drained by another.\n */\n get durable() {\n return !(this.driver instanceof MemoryQueueDriver);\n }\n\n /** See `claimsInThisProcess`. A manager built by hand always may. */\n private mayClaimHere() {\n return !this.application || claimsInThisProcess();\n }\n\n private lease(): ClaimOptions {\n return { visibilityTimeoutMs: this.config.visibilityTimeout };\n }\n\n private execute(claimed: ClaimedJob) {\n const key = `${claimed.id}:${claimed.attempt}`;\n const attempt = () => this.run(claimed);\n const done = (\n this.application\n ? kernelContext.run(this.application, attempt)\n : attempt()\n )\n .catch((error) => {\n // Only the driver's own reports reach here. The claim was not ended,\n // so its lease runs out and the job is claimed again.\n console.error(\n `The queue could not record the outcome of ${claimed.name}.`,\n error,\n );\n })\n .finally(() => {\n this.inFlight.delete(key);\n this.wake();\n });\n this.inFlight.set(key, { job: claimed, done });\n this.heartbeat();\n }\n\n /**\n * Keeps every running job's lease alive, at a third of the visibility\n * timeout so one late tick does not lose it. Stops itself once nothing is\n * running, and is unref'd, like the poll.\n */\n private heartbeat() {\n const driver = this.driver;\n if (!driver.heartbeat || this.heartbeatTimer) return;\n this.heartbeatTimer = setInterval(\n () => {\n if (this.inFlight.size === 0) {\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = undefined;\n return;\n }\n const jobs = [...this.inFlight.values()].map((e) => e.job);\n driver.heartbeat!(jobs, this.lease()).catch((error) => {\n console.error(`The queue could not extend its job leases.`, error);\n });\n },\n Math.max(1, Math.floor(this.config.visibilityTimeout / 3)),\n );\n this.heartbeatTimer.unref?.();\n }\n\n /**\n * One attempt at one claimed job, ending the claim either way.\n *\n * `onSuccess` is inside the `try`, as it always was, so a throw from it is a\n * failed attempt and is retried. `onFail` and `onDeadletter` are not: a\n * throw from either is logged and the claim still ends, where it used to\n * escape the queue with the job's slot still counted as taken.\n */\n private async run(claimed: ClaimedJob) {\n const Job = this.jobs[claimed.name];\n\n if (!Job) {\n // A driver other processes share may have handed this out because it\n // cannot filter by name, and while a blue/green ramp has both releases\n // claiming from one table, a name this replica lacks is usually one only\n // the other release has. So it goes back, without spending an attempt,\n // for a replica that has the class — until `unknownJobGrace` has passed\n // since the dispatch, after which the name is taken to be gone. Measured\n // from `createdAt` because that is all a claim carries; it is the\n // driver's clock against this one, and the skew is seconds against a\n // window of minutes. A driver that does filter only hands out an unknown\n // name once it has waited out the same window, so it normally lands\n // below; with this clock a few seconds behind the driver's, one handed\n // out right at the boundary is released instead, and — its window now\n // restarting from the release — waits one more `unknownJobGrace`. Late,\n // not lost, so no slack is subtracted for it.\n const age = Date.now() - claimed.createdAt;\n if (this.durable && age < this.config.unknownJobGrace) {\n // Once per name: with a driver that cannot filter, every poll can\n // claim the same job again, and a line per poll would bury the one\n // that matters — a replica whose discovery missed a job, say.\n if (!this.releasedNames.has(claimed.name)) {\n this.releasedNames.add(claimed.name);\n console.error(\n `Left a queued \"${claimed.name}\" for another replica: nothing is ` +\n `registered here under that name. It is dead-lettered if no ` +\n `replica has run it within unknownJobGrace ` +\n `(${this.config.unknownJobGrace}ms) of its dispatch.`,\n );\n }\n // Off this replica's own rhythm, and differently each time. It claims\n // again the moment the release lands, finds nothing due, and then\n // polls every `pollInterval`; a delay of exactly one interval made the\n // job due at the instant of that next poll, so the replica that could\n // not run it won the race for it every time. Any fixed fraction has\n // the same flaw for a replica whose polls happen to fall just before\n // the due moment each cycle — it loses every race, for good. Random\n // within one interval, every other replica's next poll has a chance.\n await this.driver.release(claimed, {\n retryInMs: Math.round(\n this.config.pollInterval * (1 + Math.random()),\n ),\n });\n return;\n }\n\n // The one place this is observable. A dispatch carries a name, the\n // registry is keyed by name, and a name nobody registered matches\n // nothing — which is exactly the silence #322 is about, except here it\n // has already happened and the work is gone. Saying so is all that is\n // left to do about it. Dead-lettered, which for the memory driver is the\n // drop it always was and for a durable one leaves a record to find.\n console.error(\n `Dropped a queued job: nothing is registered under the name ` +\n `\"${claimed.name}\". If the class exists, it was not ` +\n `discovered — check that it is under the queue slice's jobsDir ` +\n `(app/jobs by default), or list it in app/config/queue.ts.`,\n );\n await this.driver.fail(claimed, {\n error: `No job is registered under the name \"${claimed.name}\".`,\n retryInMs: null,\n });\n return;\n }\n\n let job: InstanceType<typeof Job>;\n try {\n job = new Job();\n } catch (error) {\n // A constructor or a class field that throws — `private mailer =\n // app(Mailer)` with nothing bound, say. Every other failure in here is\n // reported against the instance, and this one has no instance to report\n // against, which is exactly why it has to be caught here rather than\n // left to the generic path: that path never ends the claim, so the lease\n // lapses, the job is claimed again, and the constructor throws again,\n // once per visibility timeout, forever. The `maxAttempts` guard below\n // would normally stop that, and it cannot — answering \"how many attempts\n // does this job get?\" needs the instance that cannot be built. So it is\n // dead-lettered unrun, like a job whose arguments are not JSON: no\n // attempt of it can ever do anything but this.\n console.error(\n `Dropped a queued ${claimed.name}: it could not be constructed.`,\n error,\n );\n await this.driver.fail(claimed, {\n error: `The job could not be constructed: ${String(error)}`,\n retryInMs: null,\n });\n return;\n }\n\n let args: any[];\n try {\n args = JSON.parse(claimed.args);\n } catch (error) {\n // Not something `Job.dispatch` writes, so a driver changed it. Left\n // alone, the claim would never end and the job would be reclaimed,\n // unparseable, forever.\n console.error(\n `Dropped a queued ${claimed.name}: its arguments are not JSON.`,\n error,\n );\n await this.driver.fail(claimed, {\n error: `The arguments are not JSON: ${String(error)}`,\n retryInMs: null,\n });\n return;\n }\n\n // Claimed past its last attempt: an earlier claim used that attempt up and\n // never reported, which is what a process exiting mid-run looks like from\n // here. Running it again would exceed `maxAttempts`, so it is dead-lettered\n // unrun. `Math.max` keeps a `maxAttempts` below one meaning what it always\n // did — one attempt.\n if (claimed.attempt > Math.max(1, job.maxAttempts)) {\n const error = new Error(\n `${claimed.name} was claimed for attempt ${claimed.attempt} of ` +\n `${job.maxAttempts}: an earlier attempt never finished, most likely ` +\n `because the process running it exited. Dead-lettered without ` +\n `running it again.`,\n );\n hook(`${claimed.name}.onDeadletter`, () =>\n job.onDeadletter(error, ...args),\n );\n await this.driver.fail(claimed, {\n error: error.message,\n retryInMs: null,\n });\n await this.releaseUnique(job, args, claimed);\n return;\n }\n\n job.$claimed = { ...claimed };\n\n // A job of a cancelled batch is ended unrun. Its batch dead-lettered it\n // while it was waiting, unless it had been claimed already: its lease\n // lapsed, say, or it was waiting out a retry's claim.\n if (claimed.batchId !== undefined) {\n const batch = await this.driver.findBatch?.(claimed.batchId, { progress: false });\n if (batch?.cancelledAt != null) {\n await this.driver.fail(claimed, {\n error: `Its batch was cancelled before it ran.`,\n retryInMs: null,\n cancelled: true,\n });\n return;\n }\n const handle = this.batchHandle(claimed);\n job.batch = handle.batch;\n job.$progress = handle.progress;\n }\n\n // Per-key limits (#661), before the job runs. A job over a limit goes\n // back without spending an attempt: it is waiting for capacity, not\n // failing.\n const admitted = await this.admit(job, args, claimed);\n if (!admitted) return;\n\n let error: Error | undefined;\n let result: unknown;\n try {\n result = await (job.worker\n ? runInWorker(claimed.name, claimed.args)\n : job.run(...args));\n } catch (err) {\n error = err as Error;\n } finally {\n await admitted.done();\n }\n\n const outcome = job.$outcome;\n if (error === undefined && outcome?.kind === \"release\") {\n // `this.release(delay)`: back to waiting, the attempt taken back.\n await this.driver.release(claimed, { retryInMs: Math.max(0, outcome.delayMs) });\n return;\n }\n if (error === undefined && outcome?.kind === \"fail\") error = outcome.error;\n const retry = outcome?.kind === \"fail\" ? outcome.retry : true;\n\n if (error === undefined) {\n try {\n job.onSuccess(result, ...args);\n } catch (err) {\n error = err as Error;\n }\n }\n\n if (error !== undefined) {\n const recorded = String(error?.stack ?? error);\n hook(`${claimed.name}.onFail`, () => job.onFail(error, ...args));\n\n if (!retry || claimed.attempt >= job.maxAttempts) {\n hook(`${claimed.name}.onDeadletter`, () =>\n job.onDeadletter(error, ...args),\n );\n await this.driver.fail(claimed, { error: recorded, retryInMs: null });\n await this.releaseUnique(job, args, claimed);\n } else {\n await this.driver.fail(claimed, {\n error: recorded,\n retryInMs: backoffFor(job.backoff, claimed.attempt),\n });\n }\n return;\n }\n\n await this.driver.complete(claimed);\n await this.releaseUnique(job, args, claimed);\n }\n\n /** What `this.batch` and `this.progress()` reach in a job of a batch. */\n private batchHandle(claimed: ClaimedJob) {\n const id = claimed.batchId!;\n const driver = this.driver;\n return {\n batch: {\n id,\n cancelled: async () =>\n (await driver.findBatch?.(id, { progress: false }))?.cancelledAt != null,\n },\n progress: (value: number) => driver.reportProgress?.(claimed, value) ?? Promise.resolve(),\n };\n }\n\n /**\n * Takes a slot under the job's `concurrency` key and a hit under each of\n * its `throttle` keys, all in the queue's lock store, so the limits hold\n * across every process sharing it. Resolves to what to undo after the run,\n * or `undefined` when the job was released to wait for capacity.\n *\n * Concurrency is `limit` slot locks per key, each leased for the\n * visibility timeout and renewed while the job runs, so a slot held by a\n * dead process frees itself like the job's own lease. Throttles are fixed\n * windows counted when a job is admitted, whether it then succeeds or not.\n */\n private async admit(\n job: Job,\n args: unknown[],\n claimed: ClaimedJob,\n ): Promise<{ done(): Promise<void> } | undefined> {\n const concurrency = job.concurrency(...args);\n const throttles = [job.throttle(...args) ?? []].flat();\n if (!concurrency && throttles.length === 0) return { done: async () => {} };\n\n const locks = this.locks;\n let slot: HeldLock | undefined;\n if (concurrency && concurrency.limit > 0) {\n const ttl = this.config.visibilityTimeout;\n for (let i = 0; i < concurrency.limit && !slot; i++) {\n slot =\n (await locks.acquire(`gemi:concurrency:${concurrency.key}:${i}`, {\n ttl,\n renew: true,\n })) ?? undefined;\n }\n if (!slot) {\n await this.driver.release(claimed, {\n retryInMs: Math.round(this.config.pollInterval * (1 + Math.random())),\n });\n return undefined;\n }\n }\n\n const counted: string[] = [];\n for (const throttle of throttles) {\n const name = `gemi:throttle:${throttle.key}`;\n const hit = await locks.store.hit(name, throttle.limit, throttle.window);\n if (!hit.allowed) {\n await Promise.all(counted.map((counted) => locks.store.refund(counted)));\n await slot?.release();\n await this.driver.release(claimed, { retryInMs: Math.max(1, hit.resetInMs) });\n return undefined;\n }\n counted.push(name);\n }\n\n return {\n done: async () => {\n await slot?.release().catch((error) => {\n console.error(`[gemi] Could not free a concurrency slot of ${claimed.name}.`, error);\n });\n },\n };\n }\n}\n\n/** The lock a unique job's key takes, namespaced by the job's name. */\nfunction uniqueLockName(job: string, id: string | number) {\n return `gemi:job:${job}:${String(id)}`;\n}\n\nfunction hook(name: string, fn: () => void) {\n try {\n fn();\n } catch (error) {\n console.error(`${name} threw; the job's claim was ended anyway.`, error);\n }\n}\n\nfunction isProduction() {\n return process.env.NODE_ENV === \"production\";\n}\n\n/**\n * Whether this process should claim from a driver shared with other\n * processes: a `gemi queue:work` worker, or a server's main thread unless\n * `GEMI_QUEUE_CLAIM=off` hands its jobs to workers. `ROOT_DIR` is set only by\n * a starting server or worker, so a console command, a seed\n * or a migration — which boot the same providers — is not one, and neither is\n * a `worker` job's thread, which clones the application and exits after it.\n *\n * A worker claims whatever `GEMI_QUEUE_CLAIM` says, because the variable is\n * for the web process, and a deploy that sets it once for every container\n * would otherwise leave nothing claiming at all.\n */\nexport function claimsInThisProcess() {\n if (!isMainThread) return false;\n if (isQueueWorker()) return true;\n return process.env.ROOT_DIR !== undefined && !claimingTurnedOff();\n}\n\n/**\n * `GEMI_QUEUE_CLAIM=off` (any case): this server dispatches into a shared\n * driver and leaves the claiming to `gemi queue:work` processes. Anything else\n * claims, as before. An environment variable rather than a config field for\n * the reason `GEMI_NO_SCHEDULE` is one: the web and the worker run the same\n * build with the same config, and only the process knows which it is.\n */\nexport function claimingTurnedOff(env: Record<string, string | undefined> = process.env) {\n return (env.GEMI_QUEUE_CLAIM ?? \"\").trim().toLowerCase() === \"off\";\n}\n\n// On `globalThis` under a registry symbol, like the shutdown flag, so the mark\n// the worker entry sets is the one this module reads if two copies of it are\n// loaded. Not an environment variable: a job that spawns a child process\n// would hand it on, and the child, a script, would start claiming.\nconst QUEUE_WORKER = Symbol.for(\"gemi.queue.worker\");\n\n/** Marks this process as a `gemi queue:work` worker; see `claimsInThisProcess`. */\nexport function markQueueWorker(worker = true) {\n (globalThis as { [QUEUE_WORKER]?: boolean })[QUEUE_WORKER] = worker;\n}\n\nexport function isQueueWorker(): boolean {\n return (globalThis as { [QUEUE_WORKER]?: boolean })[QUEUE_WORKER] === true;\n}\n\nfunction resolveDriver(\n driver: Required<QueueConfig>[\"driver\"],\n application: Application | undefined,\n): QueueDriver {\n if (driver === \"memory\") return new MemoryQueueDriver();\n if (driver === \"database\" || typeof driver === \"function\") {\n // Only a manager built by hand has no application. A factory that takes\n // one would otherwise fail on `undefined` with a TypeError that names\n // neither the queue nor what is missing.\n if (!application && (driver === \"database\" || driver.length > 0)) {\n throw new Error(\n `The queue driver needs the application it belongs to, and this ` +\n `QueueManager was built without one. Pass { application }.`,\n );\n }\n if (driver === \"database\") {\n return new DatabaseQueueDriver(application!.make(DatabaseManager));\n }\n return driver(application!);\n }\n if (typeof driver === \"string\") {\n throw new Error(\n `Unknown queue driver \"${driver}\". The queue slice's driver is ` +\n `\"memory\", \"database\", a QueueDriver, or a function returning one.`,\n );\n }\n return driver;\n}\n",
|
|
18
17
|
"import { app } from \"../../foundation/app\";\nimport { type BatchStatus, type JobCall, clampProgress } from \"./batch\";\nimport type { ClaimedJob } from \"./QueueDriver\";\nimport { type DispatchedBatch, type JobBatchOptions, QueueManager } from \"./QueueManager\";\n\n/** `this.batch` inside a job dispatched with `dispatchBatch`. */\nexport type JobBatch = {\n /** The batch's id. */\n id: string;\n /**\n * Whether the batch has been cancelled — by `Job.cancelBatch`, or by a\n * failed job of a batch without `allowFailures`. Running jobs are not\n * stopped; a long one checks this between steps and returns early.\n */\n cancelled(): Promise<boolean>;\n};\n\n/**\n * The arguments `Job.with` takes for a job whose `run` ends with a\n * `BatchStatus` parameter: the ones before it, because the batch appends its\n * status when it enqueues the callback. Any other `run` takes its parameters\n * as they are.\n */\nexport type JobCallArgs<A extends any[]> = A extends [...infer Rest, infer Last]\n ? BatchStatus extends Last\n ? Rest\n : A\n : A;\n\nexport class Job {\n static name = \"unset\";\n worker = false;\n maxAttempts = 3;\n\n /**\n * Milliseconds to wait before each retry. A number is used for every retry;\n * an array gives the delay before the first retry, the second, and so on,\n * repeating its last entry. `0`, the default, retries as soon as a slot is\n * free.\n */\n backoff: number | number[] = 0;\n\n /**\n * Makes the job unique per key, across every process sharing the queue's\n * storage. Return a key from the dispatch arguments, or `undefined` for a\n * dispatch that should not be unique. While a job with the same key is\n * waiting or running, another dispatch is not queued: it resolves to the\n * id of the job already there. The key is freed when that job completes or\n * is dead-lettered, and at the latest after `uniqueFor`.\n *\n * The default returns `undefined`: a job is not unique unless it says so.\n */\n uniqueId(..._args: any[]): string | number | undefined | null {\n return undefined;\n }\n\n /**\n * How long a unique job's key is held at most, in milliseconds, so a job\n * lost with its process does not block its key forever. Default one hour.\n */\n uniqueFor = 60 * 60_000;\n\n /**\n * Rate limits per key, computed from the dispatch arguments: at most\n * `limit` jobs admitted per fixed `window` (milliseconds) under each `key`,\n * across every process sharing the queue's storage. A job over a limit is\n * put back until the window resets, without spending an attempt. Counted\n * when the job is admitted to run, whether it then succeeds or not.\n */\n throttle(..._args: any[]): JobThrottle | JobThrottle[] | undefined | null {\n return undefined;\n }\n\n /**\n * At most `limit` jobs with this `key` running at once, across every process\n * sharing the queue's storage. A job with no free slot waits, without\n * spending an attempt.\n */\n concurrency(..._args: any[]): JobConcurrency | undefined | null {\n return undefined;\n }\n\n /**\n * Called from `run`: puts the job back to wait `delayMs` once `run`\n * returns, without counting the attempt or calling any hook. For a provider\n * that answered \"slow down\". Not available to `worker` jobs.\n */\n release(delayMs = 0): void {\n this.$outcome = { kind: \"release\", delayMs };\n }\n\n /**\n * Called from `run`: fails this attempt once `run` returns, as a throw\n * would. With `retry: false` it is dead-lettered at once, whatever\n * `maxAttempts` says: for work that must not be repeated, such as a send\n * whose acceptance is uncertain. A throw after `fail(..., { retry: false })`\n * is dead-lettered too. Not available to `worker` jobs.\n */\n fail(error: unknown, options: { retry?: boolean } = {}): void {\n this.$outcome = {\n kind: \"fail\",\n error: error instanceof Error ? error : new Error(String(error)),\n retry: options.retry ?? true,\n };\n }\n\n /**\n * The batch this run belongs to, when the job was dispatched with\n * `dispatchBatch`; `undefined` otherwise. Set by the queue before `run`.\n */\n batch: JobBatch | undefined = undefined;\n\n /**\n * Called from `run` in a job of a batch: how far this job is, from 0 to 1,\n * for the batch's `progress`. A retry starts again from 0, and a job that\n * ends counts as 1 whatever it last said. Outside a batch it does nothing.\n * Each call is a write, so report at steps, not per item of a hot loop.\n */\n async progress(value: number): Promise<void> {\n const clamped = clampProgress(value);\n await this.$progress?.(clamped);\n }\n\n /** @internal Where `progress` writes; set by the queue for a job of a batch. */\n $progress: ((value: number) => Promise<void>) | undefined;\n\n /** @internal The claim this run is, set by the queue before `run`. */\n $claimed: ClaimedJob | undefined;\n\n /** @internal What `release` or `fail` asked for during this run. */\n $outcome:\n | { kind: \"release\"; delayMs: number }\n | { kind: \"fail\"; error: Error; retry: boolean }\n | undefined;\n\n run(..._args: any[]): Promise<any> | any {}\n\n onFail(_error: Error, ..._args: any[]): void {}\n onSuccess(_result: any, ..._args: any[]): void {}\n onDeadletter(_error: Error, ..._args: any[]): void {}\n\n /**\n * Queues the job and resolves to its id once the driver has recorded it.\n *\n * Not `async`, deliberately: a missing name and arguments JSON cannot carry\n * still throw here, on the caller's stack, as they did when this returned\n * `void`. Only the driver's answer is asynchronous. Ignoring the promise is\n * fine with the memory driver, whose enqueue cannot fail; with a driver\n * that can, an ignored rejection is an unhandled one, so await it.\n */\n static dispatch<T extends Job>(\n this: new () => T,\n ...args: Parameters<T[\"run\"]>\n ): Promise<string> {\n if (this.name === \"unset\") {\n throw new Error(\"Cannot dispatch a job with no name\");\n }\n\n return app(QueueManager).push(this, JSON.stringify(args));\n }\n\n /**\n * Queues one job per argument tuple as a batch, and resolves to the batch's\n * id and size once every job is recorded. The jobs, the batch and its\n * callbacks are recorded in one atomic write: all of them or none.\n *\n * ```ts\n * const { id } = await BuildPageJob.dispatchBatch(\n * pages.map((page) => [page.id, importId] as const),\n * {\n * name: `import:${importId}`,\n * allowFailures: true,\n * then: ImportFinishedJob.with(importId),\n * catch: ImportFailedJob.with(importId),\n * finally: ImportCleanupJob.with(importId),\n * },\n * );\n * ```\n *\n * Callbacks are jobs, enqueued exactly once, by whichever process ends the\n * job that makes them due, with the batch's status appended to their\n * arguments. Each job's own hooks run as usual. A worker job, a unique job\n * and a driver without batches are refused here, on the caller's stack.\n */\n static dispatchBatch<T extends Job>(\n this: new () => T,\n args: ReadonlyArray<Readonly<Parameters<T[\"run\"]>>>,\n options: JobBatchOptions = {},\n ): Promise<DispatchedBatch> {\n if (this.name === \"unset\") {\n throw new Error(\"Cannot dispatch a job with no name\");\n }\n return app(QueueManager).pushBatch(\n this,\n args.map((tuple) => JSON.stringify(tuple)),\n options,\n );\n }\n\n /**\n * A job and its arguments, without dispatching it: a batch's `then`,\n * `catch` or `finally`. When the job runs, the batch's `BatchStatus` is\n * appended to these arguments.\n */\n static with<T extends Job>(\n this: new () => T,\n ...args: JobCallArgs<Parameters<T[\"run\"]>>\n ): JobCall {\n if (this.name === \"unset\") {\n throw new Error(\"Cannot use a job with no name as a callback\");\n }\n // Thrown here, on the caller's stack, rather than when the batch is\n // recorded, for arguments JSON cannot carry.\n JSON.stringify(args);\n return { name: this.name, args };\n }\n\n /** A batch's status, or `null` for an id the queue has no batch under. */\n static findBatch(id: string): Promise<BatchStatus | null> {\n return app(QueueManager).findBatch(id);\n }\n\n /**\n * Cancels a batch that is still running, and resolves to whether it did.\n * Its waiting jobs never run; running ones finish unless they check\n * `this.batch.cancelled()`. `catch` and then `finally` run; `then` does not.\n */\n static cancelBatch(id: string): Promise<boolean> {\n return app(QueueManager).cancelBatch(id);\n }\n}\n\nexport type JobThrottle = {\n /** Shared by every job that counts against the same budget. */\n key: string;\n limit: number;\n /** The window, in milliseconds. */\n window: number;\n};\n\nexport type JobConcurrency = { key: string; limit: number };\n",
|
|
19
18
|
"import { deferUntilCommit } from \"../../../orm/context\";\nimport { Job } from \"../Job\";\nimport type { QueueManager } from \"../QueueManager\";\nimport {\n Step,\n WorkflowSuspended,\n decode,\n describe,\n encode,\n} from \"./Step\";\nimport type { WorkflowClass, WorkflowStatus } from \"./Workflow\";\nimport {\n WORKFLOW_TICK_JOB,\n type WorkflowChange,\n WorkflowLeaseLostError,\n type WorkflowRecord,\n type WorkflowRunStatus,\n type WorkflowStore,\n} from \"./WorkflowStore\";\n\nconst ENDED: readonly WorkflowRunStatus[] = [\"completed\", \"failed\", \"cancelled\"];\n\n/** How often a running `step.run` checks whether its workflow was cancelled. */\nconst CANCEL_CHECK_MS = 1000;\n\ntype Outcome =\n | { kind: \"completed\"; result: string | null }\n | { kind: \"failed\"; error: string }\n | { kind: \"suspended\" };\n\n/**\n * The queue's half of workflows: the registry of workflow classes, what\n * `Workflow.start`, `signal`, `find` and `cancel` do, and the tick.\n *\n * ### The tick\n *\n * A workflow advances only inside its tick job, which takes the workflow\n * from the store for a lease (the queue's `visibilityTimeout`, renewed while\n * it runs), runs one pass of `run`, and lets go with the outcome written in\n * the same step. Every write of the pass is fenced by that hold, so a tick\n * that lost it (it was too slow and another took over) changes nothing.\n *\n * A tick that finds the workflow held by another is dropped, after marking\n * the workflow so the holder enqueues a fresh tick when it lets go: a signal\n * that lands mid-pass is never lost, and two passes of one workflow never\n * overlap. A tick that failed or died holds the workflow under its job's id,\n * so its own retry takes it straight back.\n */\nexport class WorkflowRuntime {\n private registry: Record<string, WorkflowClass> = {};\n private storeInstance: WorkflowStore | undefined;\n private tickClass: (new () => Job) | undefined;\n private readonly reportedNames = new Set<string>();\n\n constructor(private readonly queue: QueueManager) {}\n\n /** The workflow classes this process can run, by `static name`. */\n get workflows(): Readonly<Record<string, WorkflowClass>> {\n return this.registry;\n }\n\n /** Replaces the registry. The first class to claim a name wins. */\n use(workflows: readonly WorkflowClass[]) {\n this.registry = {};\n for (const workflow of workflows) {\n if (workflow.name === \"unset\" || !workflow.name) {\n console.error(\n `A workflow class has no \\`static name\\`, so it was not registered. Add one.`,\n );\n continue;\n }\n if (this.registry[workflow.name]) {\n console.error(\n `Two workflows are named \"${workflow.name}\" — the first is registered ` +\n `and this one is not. A workflow's name is its key in storage. Rename one.`,\n );\n continue;\n }\n this.registry[workflow.name] = workflow;\n }\n }\n\n /** The internal job a workflow's passes run in, one class per manager. */\n get tickJob(): new () => Job {\n this.tickClass ??= tickJobFor(this);\n return this.tickClass;\n }\n\n get store(): WorkflowStore {\n if (!this.storeInstance) {\n const store = this.queue.driver.workflowStore?.();\n if (!store || !this.queue.driver.enqueueBatch) {\n throw new Error(\n `This queue's driver does not support workflows. The memory and ` +\n `database drivers do.`,\n );\n }\n this.storeInstance = store;\n }\n return this.storeInstance;\n }\n\n start(workflow: WorkflowClass, args: unknown[]): Promise<string> {\n if (workflow.name === \"unset\" || !workflow.name) {\n throw new Error(\"Cannot start a workflow with no name\");\n }\n const store = this.store;\n const record = {\n id: Bun.randomUUIDv7(),\n name: workflow.name,\n args: encode(args, `The arguments of ${workflow.name}`) ?? \"[]\",\n };\n const wake = () => this.queue.claimSoon();\n\n // As `QueueManager.push`: on the caller's transaction when the store\n // joins it, otherwise held until it commits.\n const joins = store.joinsTransaction?.() === true;\n if (!joins) {\n const held = deferUntilCommit(() =>\n store.create(record).then(wake, (error: unknown) => {\n console.error(\n `[gemi] The queue could not record the workflow ${workflow.name}, which ` +\n `was held until its transaction committed. The transaction stays ` +\n `committed; the workflow did not start.`,\n error,\n );\n }),\n );\n if (held) return Promise.resolve(record.id);\n }\n const written = store.create(record);\n const wakeAtCommit = joins && deferUntilCommit(wake);\n return written.then(() => {\n if (!wakeAtCommit) wake();\n return record.id;\n });\n }\n\n async signal(id: string, key: string, payload?: unknown): Promise<boolean> {\n if (typeof key !== \"string\" || key.length === 0 || key.length > 191) {\n throw new TypeError(`A signal key is a string of 1 to 191 characters.`);\n }\n const output = encode(payload, `The payload of signal \"${key}\"`);\n const taken = await this.store.update(id, { key }, ({ workflow, step, now }) => {\n if (ENDED.includes(workflow.status) || workflow.status === \"cancelling\") {\n return { result: false };\n }\n if (!step) {\n return {\n result: true,\n step: {\n workflowId: id,\n key,\n status: \"signalled\",\n attempt: 0,\n output,\n error: null,\n batchId: null,\n wakeAt: null,\n startedAt: null,\n finishedAt: now,\n createdAt: now,\n updatedAt: now,\n },\n };\n }\n if (step.status !== \"waiting\") return { result: false };\n return {\n result: true,\n step: { ...step, status: \"signalled\", output, wakeAt: step.wakeAt, finishedAt: now },\n tick: { delayMs: 0 },\n };\n });\n if (taken) this.queue.claimSoon();\n return taken === true;\n }\n\n async cancel(id: string): Promise<boolean> {\n const cancelled = await this.store.update(id, { allSteps: true }, ({ workflow, steps }) => {\n if (ENDED.includes(workflow.status) || workflow.status === \"cancelling\") {\n return { result: false };\n }\n return {\n result: true,\n workflow: { status: \"cancelling\" },\n cancelBatches: steps\n .filter((step) => step.status === \"batching\" && step.batchId !== null)\n .map((step) => step.batchId!),\n tick: { delayMs: 0 },\n };\n });\n if (cancelled) this.queue.claimSoon();\n return cancelled === true;\n }\n\n async find(id: string): Promise<WorkflowStatus | null> {\n const state = await this.store.find(id);\n if (!state) return null;\n const { workflow, steps } = state;\n let args: unknown[] = [];\n try {\n args = JSON.parse(workflow.args) as unknown[];\n } catch {}\n return {\n id: workflow.id,\n name: workflow.name,\n status: workflow.status,\n args,\n currentStep: workflow.currentStep,\n progress: workflow.progress,\n result: safeDecode(workflow.result),\n error: workflow.error,\n steps: await Promise.all(\n steps.map(async (step) => {\n const status = {\n key: step.key,\n status: step.status,\n attempt: step.attempt,\n error: step.error,\n batchId: step.batchId,\n wakeAt: step.wakeAt,\n startedAt: step.startedAt,\n finishedAt: step.finishedAt,\n };\n if (step.batchId === null) return status;\n const batch = await this.queue.driver.findBatch?.(step.batchId);\n return batch ? { ...status, progress: batch.progress } : status;\n }),\n ),\n createdAt: workflow.createdAt,\n updatedAt: workflow.updatedAt,\n };\n }\n\n /** One pass of the workflow `id`, run by its tick job. */\n async tick(id: string, job: Job): Promise<void> {\n const store = this.store;\n const claimed = job.$claimed;\n const owner = claimed\n ? `${claimed.id}:${claimed.attempt}`\n : `${crypto.randomUUID()}:1`;\n const lease = Math.max(1, this.queue.config.visibilityTimeout);\n const acquired = await store.acquire(id, owner, lease);\n if (acquired.kind !== \"acquired\") return;\n const { workflow } = acquired;\n\n const letGo = (change: Partial<WorkflowChange<undefined>> = {}) =>\n store\n .update(id, { owner }, () => ({ ...change, result: undefined, unlock: true }))\n .then(() => this.queue.claimSoon())\n .catch((error) => {\n if (!(error instanceof WorkflowLeaseLostError)) throw error;\n });\n\n if (ENDED.includes(workflow.status)) return letGo();\n\n const Class = this.registry[workflow.name];\n if (!Class) return this.unknown(workflow, job, letGo);\n\n let args: unknown[];\n try {\n args = JSON.parse(workflow.args) as unknown[];\n } catch (error) {\n return letGo({\n workflow: { status: \"failed\", error: `The arguments are not JSON: ${describe(error)}` },\n });\n }\n\n const renew = setInterval(\n () => {\n store.renew(id, owner, lease).catch((error) => {\n console.error(`[gemi] Could not extend the hold on workflow ${id}.`, error);\n });\n },\n Math.max(1, Math.floor(lease / 3)),\n );\n renew.unref?.();\n\n const cancelling = workflow.status === \"cancelling\";\n const step = new Step({\n workflowId: id,\n owner,\n store,\n steps: acquired.steps,\n cancelling,\n findBatch: (batchId) =>\n this.queue.driver.findBatch?.(batchId, { progress: false }) ?? Promise.resolve(null),\n buildBatch: (batchJob, tuples, options) =>\n this.queue.buildBatch(\n batchJob,\n tuples.map((tuple) => JSON.stringify(tuple)),\n {\n name: options.name,\n allowFailures: options.allowFailures,\n finally: { name: WORKFLOW_TICK_JOB, args: [id] },\n },\n ),\n scheduled: () => this.queue.claimSoon(),\n cancelCheckMs: CANCEL_CHECK_MS,\n });\n\n try {\n let outcome: Outcome;\n try {\n const instance = new Class();\n const value = await (cancelling\n ? instance.onCancel(step, ...args)\n : instance.run(step, ...args));\n outcome = step.suspension\n ? { kind: \"suspended\" }\n : {\n kind: \"completed\",\n result: cancelling ? null : encode(value, `The result of ${workflow.name}`),\n };\n } catch (error) {\n outcome =\n step.suspension || error instanceof WorkflowSuspended\n ? { kind: \"suspended\" }\n : { kind: \"failed\", error: describe(error) };\n if (error instanceof WorkflowLeaseLostError) step.lost = true;\n }\n // A step the code did not await (or one that ran beside a sleep in a\n // `Promise.all`) is still writing; it finishes inside this pass.\n await step.settled();\n if (step.lost) return;\n // One of those suspended the workflow after `run` had returned: it is\n // not done until that step is.\n if (outcome.kind === \"completed\" && step.suspension) outcome = { kind: \"suspended\" };\n\n await store.update(id, { owner }, ({ workflow: current, now }) =>\n this.finish(current, outcome, step, cancelling, now),\n );\n this.queue.claimSoon();\n } catch (error) {\n if (error instanceof WorkflowLeaseLostError) return;\n throw error;\n } finally {\n clearInterval(renew);\n }\n }\n\n /** The tick's last write: the pass's outcome, and letting go. */\n private finish(\n current: WorkflowRecord,\n outcome: Outcome,\n step: Step,\n cancelling: boolean,\n now: number,\n ): WorkflowChange<undefined> {\n const change: WorkflowChange<undefined> = { result: undefined, unlock: true };\n\n // Cancelled during this pass of `run`: `onCancel` is next, whatever the\n // pass came to.\n if (current.status === \"cancelling\" && !cancelling) {\n return { ...change, tick: { delayMs: 0 } };\n }\n\n if (outcome.kind === \"completed\") {\n return {\n ...change,\n workflow: cancelling\n ? { status: \"cancelled\", currentStep: null, wakeAt: null }\n : {\n status: \"completed\",\n result: outcome.result,\n progress: 1,\n currentStep: null,\n wakeAt: null,\n error: null,\n },\n };\n }\n if (outcome.kind === \"failed\") {\n return {\n ...change,\n workflow: { status: cancelling ? \"cancelled\" : \"failed\", error: outcome.error, wakeAt: null },\n };\n }\n\n const suspension = step.suspension ?? { status: \"waiting\" as const, wakes: [] };\n const next: WorkflowChange<undefined> = {\n ...change,\n workflow: {\n status: cancelling ? \"cancelling\" : suspension.status,\n currentStep: step.current ?? current.currentStep,\n },\n };\n if (suspension.wakes.length > 0) {\n const wakeAt = Math.min(...suspension.wakes);\n // A tick already scheduled no later than this one wakes the workflow\n // in time, and schedules this one itself; a second would only run the\n // pass twice.\n const scheduled =\n current.wakeAt !== null && current.wakeAt > now && current.wakeAt <= wakeAt;\n if (!scheduled) {\n next.tick = { delayMs: Math.max(0, wakeAt - now) };\n next.workflow!.wakeAt = wakeAt;\n }\n }\n return next;\n }\n\n /**\n * A tick for a workflow this process has no class for. During a\n * blue/green ramp that is usually one only the other release has, so on a\n * shared driver it goes back for another replica until `unknownJobGrace`\n * has passed since the workflow started; then it fails.\n */\n private async unknown(\n workflow: WorkflowRecord,\n job: Job,\n letGo: (change?: Partial<WorkflowChange<undefined>>) => Promise<void>,\n ) {\n const age = Date.now() - workflow.createdAt;\n if (this.queue.durable && age < this.queue.config.unknownJobGrace) {\n if (!this.reportedNames.has(workflow.name)) {\n this.reportedNames.add(workflow.name);\n console.error(\n `Left workflow \"${workflow.name}\" for another replica: nothing is ` +\n `registered here under that name.`,\n );\n }\n await letGo();\n job.release(Math.round(this.queue.config.pollInterval * (1 + Math.random())));\n return;\n }\n console.error(\n `Failed workflow ${workflow.id}: nothing is registered under the name ` +\n `\"${workflow.name}\". If the class exists, it was not discovered: check ` +\n `that it is under the queue slice's workflowsDir (app/workflows by ` +\n `default), or list it in app/config/queue.ts.`,\n );\n await letGo({\n workflow: {\n status: \"failed\",\n error: `No workflow is registered under the name \"${workflow.name}\".`,\n },\n });\n }\n\n /**\n * The tick job ran out of attempts, which only a store that stayed\n * unreachable causes. Fails the workflow if it still can, so it does not\n * sit in `running` with nothing left to advance it.\n */\n /** @internal */\n tickDeadLettered(id: string, error: Error) {\n console.error(`[gemi] The tick of workflow ${id} was dead-lettered.`, error);\n void this.store\n .update(id, {}, ({ workflow }) =>\n ENDED.includes(workflow.status)\n ? { result: undefined }\n : {\n result: undefined,\n workflow: {\n status: \"failed\",\n error: `Its tick job was dead-lettered: ${error.message}`,\n },\n unlock: true,\n },\n )\n .catch(() => {});\n }\n}\n\n/** The internal job a workflow's passes run in, bound to one runtime. */\nfunction tickJobFor(runtime: WorkflowRuntime): new () => Job {\n return class WorkflowTickJob extends Job {\n static name = WORKFLOW_TICK_JOB;\n // A tick fails only when the store cannot be reached (a workflow's own\n // errors are recorded, not thrown), so it keeps trying for a while rather\n // than leaving the workflow stuck.\n maxAttempts = 20;\n backoff = [1000, 5000, 15000, 30000, 60000];\n async run(id: string) {\n await runtime.tick(id, this);\n }\n onDeadletter(error: Error, id: string) {\n runtime.tickDeadLettered(id, error);\n }\n };\n}\n\nfunction safeDecode(output: string | null): unknown {\n try {\n return decode(output);\n } catch {\n return output;\n }\n}\n"
|
|
20
19
|
],
|
|
21
|
-
"mappings": ";qVAuCO,AAAM,LAAuC,LACzC,AACQ,FACA,QACA,WACA,YACT,WAER,WAAW,CACT,EAEA,EAAoC,CAAC,EACrC,CACA,IAAM,EAAQ,EAAQ,OAAS,aAC/B,GAAI,CAAC,2BAA2B,KAAK,CAAK,EACxC,MAAU,MACR,wBAAwB,oEAE1B,EAEF,KAAK,MAAQ,EACb,KAAK,IAAM,EAAW,IACtB,KAAK,QAAU,EAAW,QAC1B,KAAK,WA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