Skip to content
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

运行一段时间,再上报就出错了,日志如下,求解???? #26

Open
liujingdong opened this issue Jun 27, 2018 · 9 comments
Open

Comments

@liujingdong
Copy link

[2018-06-27 10:03:55.576] [DEBUG] [default] - ===== complete a message =====
[2018-06-27 10:03:55.577] [DEBUG] [default] - badjs3| {"msg":"Uncaught TypeError: window.plugins.jPushPlugin.setStatisticsOpen is not a function","target":"file:///android_asset/www/app/app.js","rowNum":297,"colNum":48,"ext":"{}","from":"file:///android_asset/www/index.html#/login","level":4,"id":3,"uin":"123","ip":"::ffff:192.168.11.106","userAgent":"Mozilla/5.0 (Linux; Android 6.0.1; vivo Y55A Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 Mobile MQQBrowser/6.2 TBS/043220 Safari/537.36","date":1530065035576}
events.js:167
throw er; // Unhandled 'error' event
^

Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
at ChildProcess.target.send (internal/child_process.js:627:16)
at Worker.send (internal/cluster/worker.js:40:28)
at Object.increase (/usr/local/crashReport-oaapp/badjs-installer/badjs-storage/service/realTotalMaster.js:30:23)
at /usr/local/crashReport-oaapp/badjs-installer/badjs-storage/storage/MongodbStorage.js:150:22
at wrappedMapper (/usr/local/crashReport-oaapp/badjs-installer/badjs-storage/node_modules/map-stream/index.js:84:19)
at Stream.stream.write (/usr/local/crashReport-oaapp/badjs-installer/badjs-storage/node_modules/map-stream/index.js:96:21)
at Stream.ondata (internal/streams/legacy.js:15:31)
at Stream.emit (events.js:182:13)
at queueData (/usr/local/crashReport-oaapp/badjs-installer/badjs-storage/node_modules/map-stream/index.js:43:21)
at next (/usr/local/crashReport-oaapp/badjs-installer/badjs-storage/node_modules/map-stream/index.js:71:7)
Emitted 'error' event at:
at ChildProcess.Worker.process.on (internal/cluster/worker.js:25:12)
at ChildProcess.emit (events.js:182:13)
at process.nextTick (internal/child_process.js:631:35)
at process._tickCallback (internal/process/next_tick.js:61:11)
[2018-06-27 10:05:05.423] [DEBUG] [default] - the operation is: log --operation: queryLogList
[2018-06-27 10:05:05.424] [DEBUG] [default] - query url : http://127.0.0.1:9000/query
[2018-06-27 10:05:05.424] [DEBUG] [default] - query param : id=3&startDate=1529891580000&endDate=1530064380000&index=0&t=%221530065105964%22&level=%5B%221%22%2C%222%22%2C%224%22%5D&=1
[2018-06-27 10:05:05.426] [WARN] [default] - error :Error: connect ECONNREFUSED 127.0.0.1:9000
^C

@liujingdong
Copy link
Author

另一段日志
[2018-06-27 10:26:29.763] [INFO] [default] - query log spend : 7ms by 3
[2018-06-27 10:35:32.741] [INFO] [default] - timeout detection , current length of client is 0
[2018-06-27 10:35:36.049] [INFO] [default] - [20922]:stringify spend time : 0
[2018-06-27 10:35:36.050] [INFO] [default] - [20922]flush cache to disk , path : /usr/local/crashReport-oaapp/badjs-installer/badjs-storage/cache/total/2018-06-27_0
fs.js:159
throw new ERR_INVALID_CALLBACK();
^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at maybeCallback (fs.js:159:9)
at Object.fs.writeFile (fs.js:1278:14)
at flushCacheToDisk (/usr/local/crashReport-oaapp/badjs-installer/badjs-storage/service/realTotalWorker.js:104:8)
at Timeout._onTimeout (/usr/local/crashReport-oaapp/badjs-installer/badjs-storage/service/realTotalWorker.js:122:9)
at ontimeout (timers.js:427:11)
at tryOnTimeout (timers.js:289:5)
at listOnTimeout (timers.js:252:5)
at Timer.processTimers (timers.js:212:10)

@loskael
Copy link
Member

loskael commented Jun 27, 2018

node 版本是多少?切换到 6.x 试试?

@liujingdong
Copy link
Author

我用的是node版本是10.4.1,谢谢

@haoshengqian
Copy link

老铁,这个问题有头绪嘛,遇到同样的问题,跑一段时间就报错ERR_IPC_CHANNEL_CLOSED

@loskael
Copy link
Member

loskael commented Jan 2, 2019

@caihuiji 来改bug了

看了一下代码,ERR_IPC_CHANNEL_CLOSED 是因为 realTotalWorker 有异常没有处理,导致 cluster.fork 的 worker 退出了,这种情况为了保证健壮性,有两个解决方案:

1、在代码 https://github.com/BetterJS/badjs-storage/blob/591e1d142607407eb37a7c88665c35d605ca96b6/service/realTotalMaster.js#L22 处新增 disconnect/error/exit(三选一即可)的事件监听,在 worker 退出时,重新 fork 一个新的

2、在代码 https://github.com/BetterJS/badjs-storage/blob/591e1d142607407eb37a7c88665c35d605ca96b6/service/realTotalWorker.js 新增一个 process unhandledRejection 和 uncaughtException 的异常处理,保证遇到未知的错误不会导致进程退出

@caihuiji
Copy link
Member

caihuiji commented Jan 3, 2019

估计node 10 ipc 有问题。 我得找时间看看 @haoshengqian 是跑起来多久会有问题哈

@haoshengqian
Copy link

默认设置下,跑一个小时就会报错ERR_IPC_CHANNEL_CLOSED,怀疑是不是某个一小时跑一次的任务导致的

@web677
Copy link

web677 commented Jan 12, 2019

关注

@xtidt
Copy link

xtidt commented Jan 16, 2020

realTotalMaster.js line:23 新增一段:
// 进程关闭事件 cluster.on('exit', (worker, code, signal) => { console.log('工作进程 %d 关闭 (%s). 重启中...', worker.process.pid, signal || code); cluster.fork(); });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants