I’m having trouble with a Node SEA project that needs to bundle a repo into an .exe file. I switched from regular puppeteer to puppeteer-core and @puppeteer/browsers to handle Chrome installation. But now I’m getting a 404 error when trying to set up a local Chrome install.
The error message looks like this:
Error in main function: Error: Got status code 404
at someFile.js:135:31
at ClientRequest.requestCallback (anotherFile.js:72:13)
at Object.onceWrapper (node:events:634:26)
at ClientRequest.emit (node:events:519:28)
I think my installation options might be wrong, but the docs don’t give much info on what values to use. Here’s my current setup:
const fileSystem = require('node:fs');
const filePath = require('node:path');
const browserManager = require('@puppeteer/browsers');
const automationTool = require('puppeteer-core');
const storageFolder = filePath.join(os.homedir(), '.PDFConverter', 'storage');
if(!fileSystem.existsSync(storageFolder)){
fileSystem.mkdirSync(filePath.join(os.homedir(), '.PDFConverter'));
fileSystem.mkdirSync(storageFolder);
}
const availableBrowsers = await browserManager.getInstalledBrowsers({storageFolder});
if(availableBrowsers.length === 0){
let browserDetails = await browserManager.install({
browser: 'chrome',
buildId: '1300313',
storageFolder,
});
}
// More puppeteer-core code here
Can anyone help me figure out what’s causing this 404 error and how to fix it? Thanks!
I’ve dealt with similar 404 errors when using @puppeteer/browsers. The issue often stems from an outdated build ID. To resolve this, try using the latest stable Chrome build ID. You can find this information in the Chromium dashboard or the @puppeteer/browsers documentation.
Another potential cause could be incorrect storage folder permissions. Ensure your script has write access to the specified path. If issues persist, consider implementing more detailed error logging to pinpoint the exact failure point.
Here’s a modified version of your installation code that might help:
const latestBuildId = 'LATEST_ID_HERE'; // Replace with actual latest ID
try {
let browserDetails = await browserManager.install({
browser: 'chrome',
buildId: latestBuildId,
storageFolder,
});
console.log('Installation successful:', browserDetails);
} catch (error) {
console.error('Installation failed:', error);
// Additional error handling or retries could be implemented here
}
This approach should provide more insight into the installation process and help identify the root cause of the 404 error.
yo dancingbird, i’ve hit that 404 error too. frustrating stuff! have u tried a newer build ID? sometimes the old ones get wonky. also, double-check ur storagefolder path - i once spent hours debugging cuz mine was off by one character lol. if that don’t work, maybe try logging the install process to see where it’s failing. good luck!
Hey there DancingBird, I’ve run into similar issues with @puppeteer/browsers before. The 404 error usually pops up when the build ID is outdated or incorrect. Have you tried using a more recent build ID?
I’d suggest checking the latest Chrome releases or the @puppeteer/browsers docs for an up-to-date build ID. In my experience, using the latest stable version often resolves these pesky 404 errors.
Also, double-check your storageFolder path. Make sure it’s correct and that your script has the necessary permissions to write to that location. I once spent hours debugging only to realize my path was slightly off!
If those don’t work, you might want to add some logging to pinpoint exactly where the installation is failing. Something like this could help:
console.log('Starting browser installation...');
try {
let browserDetails = await browserManager.install({
browser: 'chrome',
buildId: 'LATEST_BUILD_ID_HERE',
storageFolder,
});
console.log('Installation successful:', browserDetails);
} catch (error) {
console.error('Installation failed:', error);
}
Hope this helps you track down the issue. Let us know if you make any progress!