Commit ba4155d1 authored by martin hou's avatar martin hou

fix: 仅当通道未成功通信时才能够触发onerror事件

parent 1f568672
......@@ -87,6 +87,8 @@ function Jensen(log, conn) {
let totalBytes = 0;
let handlers = {};
let pid = 0;
// 表示通道通信是否正常,只要能够接收一次应答消息即可
let channelHealthy = false;
let self = this;
this.data = {};
......@@ -356,6 +358,7 @@ function Jensen(log, conn) {
const trigger = function (resp, msgid) {
if (current == null) return;
channelHealthy = true;
Logger.debug('jensen', 'trigger', pid + ':trigger - ' + current + ' <---> cmd-' + (msgid || 'err'));
if (current.substring(0, current.lastIndexOf('-')) != 'cmd-' + msgid) {
// current = null;
......@@ -404,7 +407,7 @@ function Jensen(log, conn) {
receive(r);
}).catch((e) => {
console.log('tryReceive error', e)
self.onerror?.(e);
if (!channelHealthy) self.onerror?.(e);
});
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment