Public: anyone can read this; the crew can change it.
The paid-order making watch runs its asks inside during, so main's timer test passes (#16376) #16379
grokbot/forge:timers-during → main 1 commit fork
3 files
changed +6
−2
src/actions/order.ts +4 −2
| @@ -25,6 +25,7 @@ import { checkoutOf } from "../billing/checkout.ts"; | ||
| 25 | 25 | import { getOrder, holdName, markResent, markShown, move, takeTurn, unmarkShown, pendingFrom, MAX_PENDING_PER_ADDRESS, CHECKOUT_MS, nameHeld, newId, newTicket, dropPending, pendingCount, setSession, spawnedFor, ticketFits, MAX_PENDING, type Order } from "../billing/orders.ts"; |
| 26 | 26 | import { putEntitlement } from "../billing/store.ts"; |
| 27 | 27 | import { heldOf } from "../perf/held.ts"; |
| 28 | import { during } from "../perf/jobs.ts"; | |
| 28 | 29 | import { getUserByName, type User } from "../core/users.ts"; |
| 29 | 30 | import { publicOrigin } from "../core/public_origin.ts"; |
| 30 | 31 | import { err, ok, type Result } from "../kernel/result.ts"; |
| @@ -257,7 +258,8 @@ export const makingWatch = { everyMs: ASK_MS, tries: 60 }; | ||
| 257 | 258 | /** |
| 258 | 259 | * A buyer who closed the page still gets the link by mail: this process asks after the order |
| 259 | 260 | * every `makingWatch.everyMs`, for at most `tries`, until it is no longer `making`. Holds nothing |
| 260 | * but its own timer (unref'd); a restart drops it, and the return page asks again. | |
| 261 | * but its own timer (unref'd), a sleep; each ask runs inside `during("order-making")`, so a stall | |
| 262 | * names it. A restart drops it, and the return page asks again. | |
| 261 | 263 | */ |
| 262 | 264 | async function followMaking(app: App, id: string): Promise<void> { |
| 263 | 265 | try { |
| @@ -265,7 +267,7 @@ async function followMaking(app: App, id: string): Promise<void> { | ||
| 265 | 267 | await new Promise((r) => setTimeout(r, makingWatch.everyMs).unref()); |
| 266 | 268 | const o = getOrder(app.db, id); |
| 267 | 269 | if (o?.state !== "making") return; |
| 268 | await askMaking(app, o, Date.now()); | |
| 270 | await during("order-making", () => askMaking(app, o, Date.now()), undefined, app); | |
| 269 | 271 | } |
| 270 | 272 | } catch (e) { |
| 271 | 273 | app.log.warn("a making order could not be asked after", { id, says: String(e).slice(0, 200) }); |
test/job-slices.test.ts +1
| @@ -274,6 +274,7 @@ const UNTIMED: Record<string, string> = { | ||
| 274 | 274 | ledger: "walks the cost ledger's hash chain at boot and once a day (#12273): file reads proportional to the ledger, off the request path; the fixture has no ledger", |
| 275 | 275 | "full-disk-probe": "one 64 KiB write every 2 s, only while the disk is full; the full-disk test drives probeFull directly", |
| 276 | 276 | "reach-asks": "a one-shot timer in actions/ask_host.ts, armed only while a hosted forge has an ask under an hour old: one signed call to its host over the network and a few rows; the fixture has no host", |
| 277 | "order-making": "one ask after a paid order's cloud forge every ASK_MS (actions/order.ts followMaking), only while an order is making: a row read and one probe of the forge's name over the network; the fixture has no paid orders, and order-cloud.test.ts drives the same ask through reconcileOrder", | |
| 277 | 278 | "run-ending": "a one-shot timer in runs/ending.ts, armed only while a cancel waits on a worker here: at its deadline it announces the run once (a row read and one outbox write); run-cancel-stopping.test.ts drives whenEnded directly", |
| 278 | 279 | lane: "a closure in startChecks; starting the checks service starts cell checks — follow-up", |
| 279 | 280 | "lane-catch-up": "a closure in startChecks, once on boot; same as lane", |
test/timers-named.test.ts +1
| @@ -137,6 +137,7 @@ const ALLOWED: readonly Allowed[] = [ | ||
| 137 | 137 | ["src/cli/commands/sync.ts", "resolve"], |
| 138 | 138 | ["src/cli/commands/talk.ts", "resolve"], |
| 139 | 139 | ["src/flow/lanes.ts", "resolve"], |
| 140 | ["src/actions/order.ts", "r"], | |
| 140 | 141 | ]), |
| 141 | 142 | ...allow("setTimeout", DEADLINE, [ |
| 142 | 143 | ["src/release/announce.ts", "() => res(false)"], |
new above
offline