kstulgys
kstulgys•12mo ago

So close to make puppeteer working

Total module size exceeded the zipped maximum (60.42 MiB > maximum size 42.92 MiB)
Total module size exceeded the zipped maximum (60.42 MiB > maximum size 42.92 MiB)
I'm using @sparticuz/chromium package
10 Replies
lee
lee•12mo ago
You could try making it an external dependency https://docs.convex.dev/functions/bundling#external-packages
Bundling | Convex Developer Hub
Bundling is the process of gathering, optimizing and transpiling the JS/TS
kstulgys
kstulgysOP•12mo ago
I'm doing this already I have convex.json file and including the dependency
lee
lee•12mo ago
Interesting. Can you share your convex.json? Normally external packages don't count towards the size limit
Indy
Indy•12mo ago
Another thing to check that get's missed occasionally you have to use this in a "use node"; action. https://docs.convex.dev/functions/actions#calling-third-party-apis-and-using-npm-packages
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment
kstulgys
kstulgysOP•12mo ago
@lee my convex.json that's in my nextjs root dir
{
"node": {
"externalPackages": ["@sparticuz/chromium"]
}
}
{
"node": {
"externalPackages": ["@sparticuz/chromium"]
}
}
./convex/puppeteer.ts
"use node";

import { action } from "./_generated/server";
import puppeteer from "puppeteer-core";
import chromium from "@sparticuz/chromium";

export const createPdf = action({
args: {},
handler: async () => {
const url = "https://sst.dev";
return await getPdfBase64(url);
},
});

function getPdfBase64(url:string){ ... }
"use node";

import { action } from "./_generated/server";
import puppeteer from "puppeteer-core";
import chromium from "@sparticuz/chromium";

export const createPdf = action({
args: {},
handler: async () => {
const url = "https://sst.dev";
return await getPdfBase64(url);
},
});

function getPdfBase64(url:string){ ... }
actually if I remove that external dep array then I do not have that "maximum size" error. But browser (puppeteer) still ails to launch.
lee
lee•12mo ago
It looks like you're importing "puppeteer-core" into your action, but it's not in "externalPackages" so i think it would get bundled in, instead of being installed on the server. Does it work if you expand "externalPackages" to include it?
kstulgys
kstulgysOP•12mo ago
no 😦
presley
presley•12mo ago
Can you add this back to external dependency and run npx convex dev -v. This will give detailed output of what is market as external and how big the rest is? Unfortunatelly, we have a limit on zip package that includes both bundled and external packages.
mikeysee
mikeysee•5mo ago
did you manage to get this to work in the end @kstulgys ?
kstulgys
kstulgysOP•5mo ago
nop, I think convex does not suport this, they mentioned on their docs as well

Did you find this page helpful?