Repository navigation
RFC: Plugin for edge runtime compatibility config options #19202
DanRibbens
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Written with AI
RFC: Maintained runtime compatibility defaults for Payload
@payloadcms/plugin-edgeor@payloadcms/plugin-cloudflareMotivation
We keep making tweaks for Cloudflare compatibility. Adding them to the template helps new projects, but existing users do not inherit those changes simply by updating Payload. They must discover the fix and copy the required configuration into their application.
Password-hashing PR #19070 is a concrete example: after updating, Workers users must also add
auth.passwordHashIterations: 100000to their config. With a compatibility plugin already installed and enabled, updating to a release containing that default would apply it automatically. Users could explicitly override the plugin's defaults to opt out of individual changes.The main benefit is an upgrade path for maintained compatibility defaults. Templates would install the integration once; package updates would deliver subsequent Payload-side adjustments.
Evidence from the template history
The history of
templates/with-cloudflare-d1shows repeated compatibility changes since the initial D1/R2 integration #12537:crop: falseandfocalPoint: false; #17577 documents the image-resizing limitation.payload runwebpackIgnoreto the dynamic import.serverExternalPackagesforjoseandpg-cloudflare, referencing #14656 and #14181.#15752 also adds documentation recommending native fetch for undici diagnostic-channel errors. Its diff does not add the documented
skipSafeFetchsetting to the Media collection—another example of configuration knowledge becoming scattered. This is a documented workaround, not evidence that the fetch issue was fully fixed.Not every row belongs in a Payload plugin. Build flags, framework configuration, and bindings may require separate integration helpers or template changes. The history establishes the recurring maintenance problem, not a promise that one plugin resolves every case.
Proposal
Provide an opt-in plugin that applies maintained defaults for a selected environment, preserves explicit application settings, and reports unsupported combinations.
The MongoDB adapter's existing
compatibilityOptionsprovides a useful precedent: environment-specific presets group settings that developers otherwise have to discover individually.We need more planning and thought about what we ship. The public API should not necessarily be limited to Cloudflare. A generic Workers or edge plugin could accept an environment-specific profile:
Names and profile structure are illustrative. Cloudflare would be the first candidate; this does not imply support for other edge platforms. We should compare another concrete environment before committing to a shared abstraction. “Runtime” may also be a better name than “edge” or “Workers.”
Behavior and boundaries
Configuration precedence should be:
A plugin update can therefore fix compatibility without requiring a config edit, while an explicit setting remains an opt-out. An override that violates a hard runtime constraint should produce an actionable error rather than be silently replaced.
Initial candidates are password-hashing defaults, compatible logging, and upload defaults informed by configured image-processing capabilities. The plugin should account for compatible remote transformers rather than assume every edge deployment lacks image processing. Preserve application fields, including alternative text, and verify keyboard, focus, and accessible-control behavior when rendered UI changes.
Database and storage selection remain explicit. The plugin should not automatically select D1/R2, detect the runtime and change behavior, or disable security protections. Prefer core or adapter fixes where they remove the need for a workaround. Templates remain responsible for deployment scaffolding outside the plugin's reach.
Security and upgrade policy
Shipping and validation
A new package needs its initial public npm publication and the release permissions or trusted-publishing configuration required by the existing release process. Agree on the name before publishing the prototype.
Register the package in build scripts, TypeScript references, release publishing and packing lists, workspace lockfiles, PR scopes, and applicable CI discovery or matrices. Coordinate template versions with the first published release containing the plugin and required core APIs.
Before declaring a profile supported, test defaults and overrides, validation after other integrations have configured collections, actual target-runtime execution, authentication and migration, storage/image processing, and a representative template build and deployment. Include browser/accessibility verification when UI changes. Node-only unit tests and successful package discovery in CI are insufficient evidence of runtime support.
Decisions still needed
The alternatives are to keep copying template changes, export static config presets without a plugin, or add runtime targeting to core. A plugin is useful if it makes compatibility fixes reach existing applications through routine updates while keeping explicit overrides and a clear support contract.
All reactions