Implementing Custom Renderers triggers a misleading log message about the renderer not being recognized, while it actually is (and works) #12463
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
feat: rendering
Related to prop serialization, html escaping, and framework components (scope)
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Currently, when writing Astro integrations that use the
addRenderer
API of'astro:config:setup'
, a quite misleading log message is printed with every re-render of any component that uses the custom renderer.astro/packages/astro/src/runtime/server/render/component.ts
Line 269 in 25baa4e
In my reproduction example you will find the log messages (after opening the console) despite the rendering working:
This is, because the "recognized" renderers are hardcoded:
astro/packages/astro/src/runtime/server/render/component.ts
Line 35 in 25baa4e
The actual functionality however, works flawlessly, questioning the point of the log message warning.
Why is the log message misleading?
When Astro welcomes third party developers to use the
addRenderer
API to add custom renderers, and custom renderers work well, both in SSR and client mode, because they are very well recognized by their custom name,then why would a log warning message like this make sense anymore?
I fixed this in the following PR:
#12461
Please don't be confused: In the reproduction example on CodeSandbox the issue still occurs because the dependency is pinned on the latest released
astro
version. When you check out my PR locally and run it with the commandpnpm --filter @example/framework-custom run dev
as developers are supposed to do,pnpm
actually makes sure that my changed code with the fix is used and the misleading log message is already gone.What's the expected result?
No warning log messages for custom renderers that clearly work and are recognized :)
Link to Minimal Reproducible Example
https://codesandbox.io/p/devbox/github/kyr0/astro/tree/fix/custom-renderer-warning/examples/framework-custom
Participation
The text was updated successfully, but these errors were encountered: