[Workers for Platforms] Document dynamic dispatch props - #33423
Conversation
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://docs-wfp-dynamic-dispatch-props.previews.developers.cloudflare.com (commit 4faeffc)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
|
|
||
| To create a capability, export a `WorkerEntrypoint` class from your dispatch Worker. The [`ctx.exports`](/workers/runtime-apis/context/#exports) object lets the dispatch Worker create an RPC stub for that exported class, which it can then pass to the user Worker. | ||
|
|
||
| The following example shows this pattern. The dispatch Worker uses a site ID and visitor ID to create a `Connector` capability. It passes the capability to the user Worker through `props`, without passing those IDs as separate data values. The user Worker can then call the methods exposed by `Connector`. |
There was a problem hiding this comment.
The example might read more easily if it followed the same example as above - ie one example showing how to do authorization by passing data (user-id + permissions), and one by passing a capability (user-id + Authorizer). The capability could be an Authorizer class that has a method to authorize some query without leaking details about the data behind the authorization policy.
| Cloudflare.Env, | ||
| ConnectorProps | ||
| > { | ||
| async invoke(): Promise<string> { |
There was a problem hiding this comment.
Maybe worth a passing reference to https://developers.cloudflare.com/workers/runtime-apis/rpc/#all-calls-are-asynchronous ? Or maybe just having the RPC link above to https://developers.cloudflare.com/workers/runtime-apis/rpc/#_top instead of jumping to the structured-clonable bit?
Having async on a method that is clearly sync can be otherwise confusing - it's a common surprise for RPC users.
Review
👉 Fix in your agent 👈Fix the following review findings in PR #33423 (https://github.com/cloudflare/cloudflare-docs/pull/33423).
Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
After triaging, follow this order:
1. Post a comment on this PR for any findings you are skipping, with the finding ID and your reasoning.
2. Then commit the fixes for the legitimate findings.
The comment must come before the commit — the bot reads PR comments when a new
push triggers a review, so skip comments posted after the push will be missed.
---
## Code Review
### Warnings (1)
#### CR-bf18ec3014aa · Missing required compatibility flag
- **File:** `src/content/docs/cloudflare-for-platforms/workers-for-platforms/configuration/dynamic-dispatch.mdx` line 115
- **Issue:** The new "Give access to specific platform functions" section teaches `ctx.exports.Connector({ props })` (used at line 144) without mentioning that the `ctx.exports` API requires the `enable_ctx_exports` compatibility flag. The linked reference page (`/workers/runtime-apis/context/#exports`) explicitly states this requirement in a "Compatibility flag required" note. Users copying this example with a compatibility date before 2025-11-17 will get an error (`ctx.exports` unavailable) with no hint in this doc as to why.
- **Fix:** Add a note in this section that `enable_ctx_exports` must be added to `compatibility_flags` (or that it is enabled by default only for compatibility dates on/after 2025-11-17), mirroring the note on the Context API reference page.
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Warnings (1)
ConventionsNo convention issues found. Style Guide ReviewNo style-guide issues found. CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
Summary
Documents how a Workers for Platforms dispatch Worker can pass per-request data and scoped RPC capabilities to user Workers.
props.Documentation checklist