Repository navigation
[NO-TICKET] Deliver detection reports on Nitro-built Workers (Lovable) - #451
Merged
Merged
Conversation
Lovable's current template builds with Nitro for Cloudflare Workers. Nitro calls the app's fetch with the request alone and puts the host's waitUntil on the request itself. The guard's fetch() looked for waitUntil only in an argument beside the request, so on these apps it found none and returned the 403 with the report still in flight: Cloudflare cut it off and the firewall log stayed empty while blocking worked. - hostWaitUntil finds waitUntil beside the request, on the request (request.waitUntil) or on request.runtime.cloudflare.context. The background rules check from #443 uses it too. - When a host offers none, fetch() delivers in the request as fetchGuard already does: a block waits up to 2 seconds for its report, and a detect-only report goes out on a later request once stale. The two paths share one routine. - AGENT-INSTALL.md says when reports are sent. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
🎯 Elite quality (95%) — Extracts a shared hostWaitUntil helper so Nitro-style request-attached waitUntil works for reports and rule refresh. 📦 Medium |
Contributor
Author
|
/review |
daniloradovic
approved these changes
Oct 26, 2026
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 changed
On Lovable's current template, blocking works but the firewall log stays empty. That template builds with Nitro for Cloudflare Workers.
Why the reports were lost: Cloudflare calls the Worker with
(request, env, ctx), but Nitro calls the app'sfetchwith the request alone. It puts the host'swaitUntilon the request itself (request.waitUntil, plusrequest.runtime.cloudflare.context). The guard'sfetch()only looked forwaitUntilin an argument beside the request. It found none, so it returned the 403 with the report still in flight, and Cloudflare cut the report off when the response went out.src/protect/runtime.jshostWaitUntilfindswaitUntilbeside the request, on the request, or onrequest.runtime.cloudflare.context. The background rules check from [NO-TICKET] Re-check rules in the background every 30 seconds #443 uses it too, so those checks are no longer cut off on these hosts either.waitUntilat all:fetch()now delivers within the request, asfetchGuard()has since [NO-TICKET] Deliver a blocked attack's detection before returning the 403 (reliable firewall logs on a frozen-between-requests runtime) #432. A block waits up to 2 seconds for its report to land before the 403 goes out (bounded, fail-open). A detect-only report goes out on a later request once it is 10 seconds old. Both paths share one routine (deliverInRequest).AGENT-INSTALL.md: a short "Delivery" note in "Runtime guard reporting" says when reports are sent, and the background-check sentence names wherewaitUntilis found.How it was verified
cloudflare-modulepreset) with this runtime and called it as Cloudflare does,fetch(request, env, ctx), against a stubbed Patchstack API. The attack got 403, the report was handed towaitUntil(1 item), and it reachedPOST …/detections/<uuid>. Before this change nothing was handed over.tests/protect/rules-reader.test.ts, which all fail on the previous runtime:waitUntil;runtime.cloudflare.context;waitUntil, behind a deliberately slow detections endpoint, where the report must be delivered before the 403 is returned.npm run typecheck,npm run build, fullnpm test(4625 passed),capabilities:checkare green. An earlier full run had 4 timing tests time out under load. Each passes alone, and the one touching setup takes the same ~1.2s on this branch and onmain.Rollout
@patchstack/connectand republish. No setup re-run is needed.AGENT-INSTALL.mdchanges, so the hostile field test is owed after the release that carries this, pluslovablefor doc accuracy.🤖 Generated with Claude Code