fix(core): tick the piggyback cron scheduler from the middleware request path - #1423
Closed
swissky wants to merge 1 commit into
Closed
fix(core): tick the piggyback cron scheduler from the middleware request path#1423swissky wants to merge 1 commit into
swissky wants to merge 1 commit into
Conversation
…est path PiggybackScheduler was instantiated on Cloudflare Workers but runtime.tickCron() had no call sites, so plugin cron tasks never executed. Tick once per request on both the anonymous fast path and the full runtime path; the scheduler debounces internally. Closes emdash-cms#1422
🦋 Changeset detectedLatest commit: 3c881f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Collaborator
|
Thanks. This was already fixed in #1312, which was merged today |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
On Cloudflare Workers the middleware selects the
PiggybackScheduler, whose contract is "call this from middleware on each request" — butruntime.tickCron()had no call sites, so plugin cron tasks never executed on Workers (overdue tasks sat atstatus = idleforever; details and field evidence in #1422).This adds the tick to both request branches of the middleware:
PiggybackScheduler.onRequest()debounces internally (60s) and runs fire-and-forget viaPromise.allSettled, so requests gain no latency. On Node the scheduler is theNodeCronScheduler, for whichtickCron()is a type-guarded no-op.Tests: new
middleware-cron-tick.test.ts(modeled onmiddleware-prerender.test.ts) pins one tick per request on both paths — red before the fix, green after. The existing prerender test'sMOCK_RUNTIMEgained thetickCronmember to match the runtime interface.Closes #1422
Type of change
Checklist
pnpm typecheckpasses (packages/core)pnpm lintpasses (lint:quickclean)pnpm testpasses (targeted:tests/unit/astro/middleware-*.test.ts— 13/13 green;tests/unit/astro/vite-config.test.tsfails 8/8 on my machine on unmodified main too — environmental, untouched by this PR)pnpm formathas been runemdashpatch)AI-generated code disclosure
Screenshots / test output