-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using hot-import cannot quit wechaty when quit the code #978
Comments
should add const finis = require('finis')
finis(async (code, signal) => {
const exitMsg = `Wechaty exit ${code} because of ${signal} `
await bot.stop()
console.log(exitMsg)
bot.say(exitMsg)
}) |
It seems it is not wechaty cannot quit, but some monitor thing doesn't quit. 10:37:46 INFO Bot DingDong! 我上线啦,你可以来和我订机票啦!
10:37:46 INFO Wechaty announce(DingDong! 我上线啦,你可以来和我订机票啦!)
10:37:46 VERB Wechaty announce() got 0 rooms
10:37:46 VERB Wechaty announce() to self because no room found
^C
lijiarui:~/workspace (master) $ 10:38:01 WARN PuppetWebBridge quit() page.close() exception: Error: Protocol error (Target.closeTarget): Target closed.
Wechaty exit 130 because of SIGINT
(node:36952) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: no puppet
lijiarui:~/workspace (master) $ 10:38:41 ERR HotImport importFile(/home/ubuntu/workspace/src/listeners/message.ts) rejected: TSError: ⨯ Unable to compile TypeScript
src/listeners/message.ts (8,12): Cannot find name 'BOTBUILDERAPPID'. (2304)
src/listeners/message.ts (9,18): Cannot find name 'BOTBUILDERPSW'. (2304)
src/listeners/message.ts (12,7): 'MsBot' is declared but its value is never read. (6133)
src/listeners/message.ts (12,51): Block-scoped variable 'startBot' used before its declaration. (2448)
src/listeners/message.ts (12,51): Variable 'startBot' is used before being assigned. (2454)
10:38:41 ERR HotImport refreshImport(/home/ubuntu/workspace/src/listeners/message.ts) exception: TSError: ⨯ Unable to compile TypeScript
src/listeners/message.ts (8,12): Cannot find name 'BOTBUILDERAPPID'. (2304)
src/listeners/message.ts (9,18): Cannot find name 'BOTBUILDERPSW'. (2304)
src/listeners/message.ts (12,7): 'MsBot' is declared but its value is never read. (6133)
src/listeners/message.ts (12,51): Block-scoped variable 'startBot' used before its declaration. (2448)
src/listeners/message.ts (12,51): Variable 'startBot' is used before being assigned. (2454)
10:38:41 ERR HotImport refreshImport(/home/ubuntu/workspace/src/listeners/message.ts) keep using the latest usable version
10:38:41 ERR HotImport importFile(/home/ubuntu/workspace/src/listeners/message.ts) rejected: TSError: ⨯ Unable to compile TypeScript
src/listeners/message.ts (8,12): Cannot find name 'BOTBUILDERAPPID'. (2304) Then, I found node still running on the background lijiarui:~/workspace (master) $ ps -A
PID TTY TIME CMD
1 ? 00:00:01 tini
7 ? 00:00:00 micro-inetd
34436 ? 00:00:00 tmux
34437 pts/1 00:00:00 bash
34438 pts/1 00:00:00 bash
36045 ? 00:00:00 dropbear
36046 ? 00:00:01 vfs-worker {"pi
36493 pts/0 00:00:00 tmux
36952 pts/1 00:00:04 node
37062 pts/1 00:00:00 ps code as follows: import { Wechaty, Room } from 'wechaty'
import { log, TICKETBOT_SECRET } from './config'
export const bot = Wechaty.instance()
const finis = require('finis')
bot
.on('scan', './listeners/scan')
.on('logout', './listeners/logout')
.on('error', './listeners/error')
.on('login', './listeners/login')
.on('message', './listeners/message')
.start()
.catch(async function(e) {
log.error('Bot', 'init() fail: %s', e)
await bot.stop()
process.exit(-1)
})
finis(async (code, signal) => {
const exitMsg = `Wechaty exit ${code} because of ${signal} `
await bot.stop()
console.log(exitMsg)
}) |
I found the solution! should add finis(async (code, signal) => {
const exitMsg = `Wechaty exit ${code} because of ${signal} `
await bot.stop()
console.log(exitMsg)
process.exit(-1)
}) Actually, I think it should be done by wechaty itself instead by user, because wechaty is a 'platform' solution. |
Your solution looks like a dirty fix. What if you remove all the finis part of the code? |
If I remove all finis part, when I quit the code, node and chrom also work background, as the following shows https://login.weixin.qq.com/qrcode/4Y04lLO_YQ==
14:22:39 INFO Listeners/Scan https://login.weixin.qq.com/qrcode/4Y04lLO_YQ==
[0]
^C
lijiarui:~/workspace (master) $ ps -A
PID TTY TIME CMD
1 ? 00:00:01 tini
7 ? 00:00:00 micro-inetd
34436 ? 00:00:00 tmux
34437 pts/1 00:00:00 bash
34438 pts/1 00:00:00 bash
37393 pts/1 00:00:00 node
37403 pts/1 00:00:44 node
37647 pts/3 00:00:00 bash
37648 pts/3 00:00:00 bash
40297 ? 00:00:00 dropbear
40298 ? 00:00:01 vfs-worker {"pi
40465 pts/0 00:00:00 tmux
40467 pts/2 00:00:00 tmux
41227 pts/3 00:00:06 node
41300 ? 00:00:02 chrome
41305 ? 00:00:00 chrome
41326 ? 00:00:00 chrome
41333 ? 00:00:10 chrome
41374 pts/3 00:00:00 ps code as follows import { Wechaty, Room } from 'wechaty'
export const bot = Wechaty.instance()
bot
.on('scan', './listeners/scan')
.on('logout', './listeners/logout')
.on('error', './listeners/error')
.on('login', './listeners/login')
.on('message', './listeners/message')
.start()
.catch(async function(e) {
log.error('Bot', 'init() fail: %s', e)
await bot.stop()
process.exit(-1)
}) |
I do not think this issue relates to |
Due to a typescript bug |
When I Using hot-import of wechaty, when I quit the code, but it seems wechaty still work background, log as follows.
The text was updated successfully, but these errors were encountered: