Closed cyai closed 1 week ago
What version of Hero are you using, and can you share more of your setup?
Version: "@ulixee/hero-playground": "^2.0.0-alpha.28"
So in my project I have set up a bullmq queue to manage tasks and when a task is loaded in the queue then the hero instance is created and then further activities are performed. The error I am getting is right at the place where the hero instance is created:
return new Hero({
showChromeInteractions: true,
showChrome: true,
userProfile: theStoredProfile,
});
Hero Playground is only meant to be used for testing. It's an easy start up and shut down after a single scrape project. I don't know if you might have another one stuck around in the background? It could help to switch to full stack: https://ulixee.org/docs/hero/advanced-concepts/deployment#fullstack
Hi. I was getting the exactly same error. Using playground, now I've made a simple code,
`const HeroCore = require('@ulixee/hero-core'); const { TransportBridge } = require('@ulixee/net'); const Hero = require('@ulixee/hero'); const { ConnectionToHeroCore } = require('@ulixee/hero');
const bridge = new TransportBridge(); const connectionToCore = new ConnectionToHeroCore(bridge.transportToCore); const heroCore = new HeroCore(); heroCore.addConnection(bridge.transportToClient);
async function routes(fastify, options) { fastify.get('/nyt', async (request, reply) => { let hero; try { hero = new Hero({ connectionToCore, showBrowser: false }); await hero.goto('https://www.nytimes.com/international/'); await hero.waitForPaintingStable(); const body = await hero.document.body.innerHTML; return body; } catch (error) { console.error('Error:', error); reply.status(500).send('An error occurred while fetching the page'); } finally { if (hero) { await hero.close(); } } }); }
module.exports = routes;`
And I deployed to render.com. And now I'm getting this error. Error: Error: Failed to launch chrome 124.0.6367.78: Please re-install the browser engine:
To be honest, I didn't find the documentation very clear in this regard. I read it exactly here: https://ulixee.org/docs/hero/advanced-concepts/deployment#fullstack
@pedrosarkis Your code looks right, and I would guess this works fine on a local machine. I think you're likely experiencing an issue that has to do with how your code got packaged up for your hosting service. Hero needs to have a copy of chrome downloaded, which it does through a User's cache dir. You're right that the directions are very unhelpful for how to get Hero running on these kinds of hosting services - they all tend to have quirks for what directories are available and what post install scripts can be run.
I don't have any idea how to help you troubleshoot if this is indeed the hosting service. If it doesn't work for you locally, then something else is going on, and you are welcome to provide more details.
If not, my guess is that it will have something to do with one of these:
Hero runs a postinstall script to download Chrome and a Socket Connect native library.
Hero will store data outside the node_modules to:
A linux deployment also sometimes needs extra dependencies to be installed via
sudo $(npx install-browser-deps)
I am getting
Error: listen EADDRINUSE: address already in use
whenever I try to open a browser instance using hero.I tried to check if the port that I am running my node project is occupied but turns out that the port is free and no other services is running on it.
System Version: macOS 14.5 (23F79)
The entire error: