Abdul
Abdul•3mo ago

Unable to push deployment config when using @react-pdf/renderer

Hi, I am using @react-pdf/renderer in one of my node actions but having issues in deployment. I have added convex.json file alongside package.json file as follows:
{
"node": {
"externalPackages": [
"*"
]
}
}
{
"node": {
"externalPackages": [
"*"
]
}
}
Can someone please confirm if this package has some known issue when used with Convex's node runtime? Thanks
No description
9 Replies
ballingt
ballingt•3mo ago
Are you using @react-pdf/renderer only from a file with "use node" at the top, and are any other files importing that file? No known issues, and the repo for that library says it works on Lambda
Abdul
AbdulOP•3mo ago
it's only one action with 'use node' at the top and it imports another one which has the layout pdf.ts
'use node'
import React from "react";
import { action } from "./_generated/server";
import { renderToStream, renderToBuffer } from "@react-pdf/renderer";
import MyDocument from "./Document";

export const generatePdf = action({
handler: async () => {
const doc = React.createElement(MyDocument, {});
console.log('Rendering PDF stream');
await renderToBuffer(doc);

return "PDF generated successfully"
}
})
'use node'
import React from "react";
import { action } from "./_generated/server";
import { renderToStream, renderToBuffer } from "@react-pdf/renderer";
import MyDocument from "./Document";

export const generatePdf = action({
handler: async () => {
const doc = React.createElement(MyDocument, {});
console.log('Rendering PDF stream');
await renderToBuffer(doc);

return "PDF generated successfully"
}
})
ballingt
ballingt•3mo ago
But does any other file import this file?
Abdul
AbdulOP•3mo ago
no this file only exports the action and it's not imported by any other file
ballingt
ballingt•3mo ago
Is Document.js a "use node" file too?
Abdul
AbdulOP•3mo ago
nope
ballingt
ballingt•3mo ago
This error message is saying Document.js can't be analyzed as a non-"use node" file so either move Document outside of the convex/ directory, or add "use node" to it
Abdul
AbdulOP•3mo ago
Oh it worked after adding 'use node' on the Document.tsx file thank you so much for your help 🙂 sorry to miss that part in the error message.
ballingt
ballingt•3mo ago
Not on you, it could be clearer!

Did you find this page helpful?