chromium
chromium copied to clipboard
[BUG] Protocol Mismatch
Environment
-
chromium
Version: 123.0.1 -
puppeteer
/puppeteer-core
Version: 22.6.5 - Node.js Version: 18.16.0
- Lambda / GCF Runtime: 18.20.2
Expected Behavior
Puppeteer launched normally ( i run it at local first )
Current Behavior
Error: protocol mismatch after a while
Steps to Reproduce
the code is exactly same as example remote-min-binary
const puppeteer = require("puppeteer-core");
const chromium = require("@sparticuz/chromium-min");
const handler = async () => {
try {
const browser = await puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath(
"https://github.com/Sparticuz/chromium/releases/download/v123.0.1/chromium-v123.0.1-pack.tar"
),
headless: chromium.headless,
ignoreHTTPSErrors: true,
});
const page = await browser.newPage();
await page.goto("https://www.example.com", { waitUntil: "networkidle0" });
console.log("Chromium:", await browser.version());
console.log("Page Title:", await page.title());
await page.close();
await browser.close();
} catch (error) {
throw new Error(error.message);
}
};
handler().then(() => console.log("Done"));
As i searched again, this package chromium-min is just for linux, is it true? can i used it in windows? i want to deploy it at netlify server cuz it limit was 50mb, then i try to using chromium-min and use external chromium (your github tar exactly), but it cannot launched as it normally thx.
same issue here, regardless if I use my own hosted version on azure blob storage or the github one:
async function getBrowser() {
if (process.env.VERCEL_ENV === "production") {
// Production settings on Vercel using the -min package
const chromiumPackUrl = "https://privateblobstoragename.blob.core.windows.net/chromium-binaries/chromium-v121.0.0-pack.tar";
const executablePath = await chromium.executablePath(chromiumPackUrl);
return puppeteerCore.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath,
headless: chromium.headless, // true on server environments
});
} else {
// Local development settings
const localExecutablePath = process.env.CHROME_EXECUTABLE_PATH || 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe';
return puppeteerCore.launch({
executablePath: localExecutablePath,
headless: true, // Set to false if you need a GUI
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
}
}
I get this:
✓ Compiled /api/generate-pdf in 119ms (215 modules)
⨯ AssertionError [ERR_ASSERTION]: protocol mismatch
at Object.request (C:\source\tml\tmladmin\tmladminui\node_modules\follow-redirects\index.js:530:14)
at Object.get (C:\source\tml\tmladmin\tmladminui\node_modules\follow-redirects\index.js:537:44)
at C:\source\tml\tmladmin\tmladminui\node_modules\@sparticuz\chromium-min\build\helper.js:56:10
at new Promise (<anonymous>)
at downloadAndExtract (C:\source\tml\tmladmin\tmladminui\node_modules\@sparticuz\chromium-min\build\helper.js:50:43)
at Chromium.executablePath (C:\source\tml\tmladmin\tmladminui\node_modules\@sparticuz\chromium-min\build\index.js:244:78)
at Chromium.executablePath (C:\source\tml\tmladmin\tmladminui\node_modules\@sparticuz\chromium-min\build\index.js:244:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getBrowser (webpack-internal:///(api)/./pages/api/generate-pdf.js:18:32)
at async __WEBPACK_DEFAULT_EXPORT__ (webpack-internal:///(api)/./pages/api/generate-pdf.js:46:21) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: 'c:',
expected: 'https:',
operator: '==',
page: '/api/generate-pdf'
}
on this line:
const executablePath = await chromium.executablePath(chromiumPackUrl);
running on localhost
the fact that it says
code: 'ERR_ASSERTION', actual: 'c:', expected: 'https:', operator: '==', page: '/api/generate-pdf'
with expected being https: and actual being c: makes it look like it is trying to access a local file, while the value of the chromiumPackUrl really is an https link
I have double checked the npm installed version is 121.0.0. Also tried with 123.0.1 as module and as tar file --> same result
Same error here, any way to fix? @Sparticuz
same here
same
same issue
Same here
same
same issue
Finally I choose "Render" to host my App. You should use a Dockerfile to init Puppeteer. It was the only solution for this problem.
Reference: https://www.youtube.com/watch?v=6cm6G78ZDmM&t=1s
FROM ghcr.io/puppeteer/puppeteer:22.10.0
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci
COPY . .
CMD [ "node", "api/index.js" ]```