wechaty / matrix-appservice

Wechaty [Matrix] Application Services Bridge
https://matrix.org/docs/projects/bridge/matrix-appservice-wechaty
Apache License 2.0
131 stars 16 forks source link

"failed stated PuppetWeChatBridge" #78

Closed lprintf closed 3 years ago

lprintf commented 3 years ago

Failed to Start PuppetWeChatBridge with the Envirenment X64.

Self-Diagnosis

Environment(for bug reports)

My configuration/Related code

WECHATY_PUPPET=wechaty-puppet-wechat

Steps to Reproduce the Issue

run WECHATY_PUPPET=wechaty-puppet-wechat LOG_LEVEL=silly ts-node bin/matrix-appservice-wechaty.ts --config config/config.yaml --file wechaty-registration.yaml directly in centos7 x64

Current Result (Include screenshots where appropriate.)

23:12:53 VERB PuppetWeChatBridge initBrowser() with options={"args":["--audio-output-channels=0","--disable-default-apps","--disable-translate","--disable-gpu","--disable-setuid-sandbox","--disable-sync","--hide-scrollbars","--mute-audio","--no-sandbox"],"headless":true}
23:12:53 ERR PuppetWeChatBridge start() exception: Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (848005).
23:12:53 SILL StateSwitch <PuppetWeChatBridge> off() is false
23:12:53 VERB StateSwitch <PuppetWeChatBridge> off(true) <- (false)
23:12:53 ERR PuppetWeChat initBridge() exception: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (848005).
23:12:53 VERB PuppetWeChatBridge stop()
23:12:53 ERR PuppetWeChat initBridge() this.bridge.stop() rejection: Error: no page
23:12:53 ERR PuppetWeChat start() exception: Error
Error: 
    at PuppetWeChat.<anonymous> (/home/ylin/Documents/matrix-appservice-wechaty/node_modules/wechaty/src/wechaty.ts:444:32)
    at PuppetWeChat.emit (events.js:315:20)
    at PuppetWeChat.EventEmitter.emit (domain.js:467:12)
    at PuppetWeChat.start (/home/ylin/Documents/matrix-appservice-wechaty/node_modules/wechaty/node_modules/wechaty-puppet-wechat/src/puppet-wechat.ts:201:12)
    at Wechaty.start (/home/ylin/Documents/matrix-appservice-wechaty/node_modules/wechaty/src/wechaty.ts:726:7)
    at async Promise.all (index 0)
    at Object.run (/home/ylin/Documents/matrix-appservice-wechaty/src/cli/run.ts:57:3)
...

Expected Result

I will propose a pull request after my last pull request haved been deal if appropriate. If it is not appropriate, please stop me and point my faults.

Further explanation:

It seem a bug about puppeteer, and similliar to https://github.com/berstend/puppeteer-extra/issues/471 and https://stackoverflow.com/questions/53997175/puppeteer-error-chromium-revision-is-not-downloaded.

I have avoid it by install chrome and add some modifications in a commit such as follow:

  if(process.env.SIMULATED){
    // XXX This is aim to use the chrome referred by /usr/bin/chromium-browser as dependency of wechaty.node_modules.puppeteer module.
    Object.defineProperty(process, 'arch', {
      value: process.env.SIMULATED,
    });
  }

I am not familiar with the open source project contribution process. I will propose a pull request after my last pull request haved been deal if appropriate.

huan commented 3 years ago

Thanks for creating this issue and the explanation!

I have two questions after reviewed the PR and read the links that you provided:

  1. Did you tried the Remove puppeteer-core from your dependencies. suggestion from issue 471?
  2. Have you tried the answer from https://stackoverflow.com/questions/53997175/puppeteer-error-chromium-revision-is-not-downloaded by adding executablePath: '/usr/bin/chromium-browser' to puppeteer options?
lprintf commented 3 years ago

Yes, This is not a good way to solve the problem only avoid it temporarily. But this project is not dependented puppeteer derectly. A better solution is to update the puppeteer of wechaty. And there is a debug script disscuss more. Let me try more.

lprintf commented 3 years ago

emmm, I use the endpoint: '/usr/bin/chromium-browser' and solve this problem. I will try more before commit in the future.

huan commented 3 years ago

Great to know that you have solved this problem by setting the puppetOptions.

It would be great if you can write your solution by adding a TroubleShooting section in the README so that it can help future developers who run into the same issue that you have.

lprintf commented 3 years ago

Great to know that you have solved this problem by setting the puppetOptions.

It would be great if you can write your solution by adding a TroubleShooting section in the README so that it can help future developers who run into the same issue that you have.

OK, it have been record. And I have updated the PR #79 now.

lprintf commented 3 years ago

When I install dependency in wechaty-puppet-wechat, It will install chrominum automaticly and needn't set chromium path by myself. But set the chromium path manually is a easy way to solve this problem.

> puppeteer@7.1.0 install /home/ylin/Documents/wechaty-puppet-wechat/node_modules/puppeteer
> node install.js

Downloading Chromium r848005 - 138.2 Mb [====================] 100% 0.0s 
Chromium (848005) downloaded to /home/ylin/Documents/wechaty-puppet-wechat/node_modules/puppeteer/.local-chromium/linux-848005

> core-js@3.15.2 postinstall /home/ylin/Documents/wechaty-puppet-wechat/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
lprintf commented 3 years ago

https://github.com/wechaty/wechaty-puppet-wechat/pull/143