ulixee / hero

The web browser built for scraping
MIT License
649 stars 32 forks source link

Chrome crashing on startup #189

Closed shstkvch closed 1 year ago

shstkvch commented 1 year ago

Hi, really love the motivation behind this project, it looks awesome.

I've been trying to get Hero to run on my mac (Node 18.5, osx Monterey 12.6) , but it just crashes straight away.

I have a file set up with the example code:

const Hero = require('@ulixee/hero-playground');

(async () => {
  const hero = new Hero();
  await hero.goto('https://example.org');
  const title = await hero.document.title;
  const intro = await hero.document.querySelector('p').textContent;
  await hero.close();
})();

I've installed the deps with yarn. When I run node test.js I get the error below. Would appreciate any suggestions in getting this running! Cheers.

Started Ulixee Miner at localhost:59702
2022-11-16T18:06:19.137Z ERROR [hero-core/connections/ConnectionToHeroClient] ConnectionToClient.HandleRequestError { context: {}, sessionId: undefined, sessionName: undefined } BrowserLaunchError: Could not write to connection with Browser Process: write EPIPE
------BROWSER_CREATION_Q--------------------------
    at Queue.run (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/commons/lib/Queue.ts:40:19)
    at Pool.getBrowser (/Users/david/Documents/htdocs/tmp/hero/test/agent/core/lib/Pool.ts:124:44)
    at Agent.open (/Users/david/Documents/htdocs/tmp/hero/test/agent/core/lib/Agent.ts:108:34)
    at async Session.openBrowser (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/core/lib/Session.ts:389:5)
    at async Function.create (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/core/lib/Session.ts:876:7)
    at async ConnectionToHeroClient.createSession (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/core/connections/ConnectionToHeroClient.ts:187:30)
    at async CommandRunner.runFn (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/core/lib/CommandRunner.ts:36:14)
    at async ConnectionToHeroClient.executeCommand (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/core/connections/ConnectionToHeroClient.ts:249:12)
    at async ConnectionToHeroClient.handleRequest (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/core/connections/ConnectionToHeroClient.ts:64:14) {
  isSandboxError: false
}
Automatically shutting down Hero Core (Browser Closed)
2022-11-16T18:06:19.156Z ERROR [hero-core/index] UnhandledErrorOrRejection { context: {}, sessionId: null, sessionName: undefined } Error: The socket was closed while data was being compressed
    at /Users/david/Documents/htdocs/tmp/hero/test/node_modules/ws/lib/sender.js:342:21
    at /Users/david/Documents/htdocs/tmp/hero/test/node_modules/ws/lib/permessage-deflate.js:325:9
    at PerMessageDeflate.cleanup (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/ws/lib/permessage-deflate.js:142:9)
    at WebSocket.emitClose (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/ws/lib/websocket.js:241:57)
    at Receiver.receiverOnFinish (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/ws/lib/websocket.js:1058:20)
    at Receiver.emit (node:events:537:28)
    at finish (node:internal/streams/writable:748:10)
    at node:internal/streams/writable:726:13
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
2022-11-16T18:06:19.160Z ERROR [hero-core/index] UnhandledErrorOrRejection { context: {}, sessionId: null, sessionName: undefined } DisconnectedFromCore: This transport has been disconnected (host: This Hero has been disconnected from Core (coreHost: ws://localhost:59702))
    at ConnectionToHeroCore.beforeDisconnect (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/client/connections/ConnectionToHeroCore.ts:104:11)
    at ConnectionToHeroCore.onConnectionTerminated (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/net/lib/ConnectionToCore.ts:240:42)
    at Object.onceWrapper (node:events:652:26)
    at WsTransportToCore.emit (node:events:537:28)
    at WsTransportToCore.emit (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/commons/lib/TypedEventEmitter.ts:136:18)
    at WsTransportToCore.disconnect (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/net/lib/WsTransportToCore.ts:68:10)
    at Object.onceWrapper (node:events:652:26)
    at WebSocket.emit (node:events:537:28)
    at WebSocket.emitClose (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/ws/lib/websocket.js:246:10)
    at Socket.socketOnClose (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/ws/lib/websocket.js:1148:15)
------AGENT QUEUE---------------------------------
    at Queue.run (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/commons/lib/Queue.ts:40:19)
    at CoreSessions.create (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/client/lib/CoreSessions.ts:30:8)
    at ConnectionToHeroCore.createSession (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/client/connections/ConnectionToHeroCore.ts:57:38)
    at Hero._Hero_getCoreSessionOrReject (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/client/lib/Hero.ts:585:10)
    at Hero.get activeTab [as activeTab] (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/client/lib/Hero.ts:140:33)
    at Hero.goto (/Users/david/Documents/htdocs/tmp/hero/test/node_modules/client/lib/Hero.ts:424:17)
    at /Users/david/Documents/htdocs/tmp/hero/test/test.js:5:14
    at Object.<anonymous> (/Users/david/Documents/htdocs/tmp/hero/test/test.js:9:3)
    at Module._compile (node:internal/modules/cjs/loader:1112:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1166:10) {
  host: 'This Hero has been disconnected from Core (coreHost: ws://localhost:59702)',
  code: 'DisconnectedFromCore',
  coreHost: 'ws://localhost:59702'
}
2022-11-16T18:06:20.135Z ERROR [unblocked-agent/lib/BrowserProcess] ERROR launching browser {
  stderr: "dlopen /Users/david/Library/Caches/ulixee/chrome/105.0.5195.125/Google Chrome.app/Contents/MacOS/../Frameworks/Google Chrome Framework.framework/Versions/105.0.5195.125/Google Chrome Framework: dlopen(/Users/david/Library/Caches/ulixee/chrome/105.0.5195.125/Google Chrome.app/Contents/MacOS/../Frameworks/Google Chrome Framework.framework/Versions/105.0.5195.125/Google Chrome Framework, 0x0105): tried: '/Users/david/Library/Caches/ulixee/chrome/105.0.5195.125/Google Chrome.app/Contents/MacOS/../Frameworks/Google Chrome Framework.framework/Versions/105.0.5195.125/Google Chrome Framework' (slice 0 extends beyond end of file, slice 1 extends beyond end of file, fat file, but missing compatible architecture (have (x86_64,arm64), need (x86_64h))), '/Library/Frameworks/Google Chrome Framework.framework/Versions/105.0.5195.125/Google Chrome Framework' (no such file), '/System/Library/Frameworks/Google Chrome Framework.framework/Versions/105.0.5195.125/Google Chrome Framework' (no such file), '/Users/david/Library/Caches/ulixee/chrome/105.0.5195.125/Google Chrome.app/Contents/Frameworks/Google Chrome Framework.framework/Versions/105.0.5195.125/Google Chrome Framework' (slice 0 extends beyond end of file, slice 1 extends beyond end of file, fat file, but missing compatible architecture (have (x86_64,arm64), need (x86_64h))), '/Library/Frameworks/Google Chrome Framework.framework/Versions/105.0.5195.125/Google Chrome Framework' (no such file), '/System/Library/Frameworks/Google Chrome Framework.framework/Versions/105.0.5195.125/Google Chrome Framework' (no such file).",
  context: {},
  sessionId: undefined,
  sessionName: undefined
}
shstkvch commented 1 year ago

Update: I got it to work with the following:

  1. rm -rf ~/Library/Caches/ulixee/
  2. rm -rf node_modules yarn.lock
  3. npm install && npm rebuild

For some reason this worked, not sure why it didn't with yarn. But there we go!