T
TanStack2mo ago
conscious-sapphire

Can't use "@react-pdf/renderer" client side in the RC

After updating to RC, it's no longer possible to use "@react-pdf/renderer" in the client-side; we receive this error directly when visiting the page that uses it:
TypeError: inherits4 is not a function
at node_modules/queue/index.js (@react-pdf_renderer.js?v=c121c985:439:5)
at __require2 (chunk-VHXUCOYC.js?v=34d49e13:20:50)
at @react-pdf_renderer.js?v=c121c985:13170:28
TypeError: inherits4 is not a function
at node_modules/queue/index.js (@react-pdf_renderer.js?v=c121c985:439:5)
at __require2 (chunk-VHXUCOYC.js?v=34d49e13:20:50)
at @react-pdf_renderer.js?v=c121c985:13170:28
To reproduce:
import { Document } from "@react-pdf/renderer";

function RouteComponent() {
console.log(Document);
return <div/>
}
import { Document } from "@react-pdf/renderer";

function RouteComponent() {
console.log(Document);
return <div/>
}
Maybe the problem comes from "@react-pdf/renderer" but in version ^1.131 it worked pretty well
14 Replies
united-yellow
united-yellow2mo ago
add @react-pdf/renderer to ssr.noExternal in the vite config
conscious-sapphire
conscious-sapphireOP2mo ago
Oh thanks I'll try that This didn't work for me, I migrated PDF generation to server side
united-yellow
united-yellow2mo ago
what happened with this setting?
conscious-sapphire
conscious-sapphireOP2mo ago
same issue Oh! I just tested with @tanstack/nitro-v2-vite-plugin it works, but with nitro-nightly it doesn't work
united-yellow
united-yellow2mo ago
and with nitro3 alpha ( not nightly)?
conscious-sapphire
conscious-sapphireOP2mo ago
I hadn't seen the new update of the doc, I just tested it now and still the same error message:
TypeError: inherits4 is not a function
at node_modules/queue/index.js (@react-pdf_renderer.js?v=88097b61:439:5)
at __require2 (chunk-VHXUCOYC.js?v=88097b61:20:50)
at @react-pdf_renderer.js?v=88097b61:13170:28

The above error occurred in the <Lazy> component.

React will try to recreate this component tree from scratch using the error boundary you provided, CatchBoundaryImpl.
TypeError: inherits4 is not a function
at node_modules/queue/index.js (@react-pdf_renderer.js?v=88097b61:439:5)
at __require2 (chunk-VHXUCOYC.js?v=88097b61:20:50)
at @react-pdf_renderer.js?v=88097b61:13170:28

The above error occurred in the <Lazy> component.

React will try to recreate this component tree from scratch using the error boundary you provided, CatchBoundaryImpl.
With @tanstack/nitro-v2-vite-plugin it seems to work fine now, even without ssr.noExternal config, (I think there was a conflict with the dependencies because before I had both versions of Nitro installed at the same time)
united-yellow
united-yellow2mo ago
might be worth raising this issue at nitro then either it's a bug or a misconfiguration
conscious-sapphire
conscious-sapphireOP2mo ago
Yes I will report that, the problem is that with Nitro there is also Bcrypt which did not work in the build so I downgraded to v2 which works much better, thank you I will report these two problems to Nitro
united-yellow
united-yellow2mo ago
ideally you can reproduce them in a pure nitro project, wihout start
united-yellow
united-yellow2mo ago
GitHub
vite-examples/examples/react-ssr at main · nitrojs/vite-examples
Nitro v3 + Vite Examples. Contribute to nitrojs/vite-examples development by creating an account on GitHub.
conscious-sapphire
conscious-sapphireOP2mo ago
Oh thank you!
united-yellow
united-yellow2mo ago
this might have just been fixed here
united-yellow
united-yellow2mo ago
GitHub
fix(vite): remove noExternal: true from service environment build...
🔗 Linked issue I think this can be removed from each service build since final nitro environment has noExternal: true, which can take care bundling up dependencies. Currently it&amp;#39;s causing ...
conscious-sapphire
conscious-sapphireOP2mo ago
sorry didn't really understand, I just tested with the react-ssr example, and indeed I have the same error message, and therefore the same bug. so i can report this issue to Nitro

Did you find this page helpful?