@yarkivaev/scada 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -82,6 +82,12 @@ async function connect(state, epoch) {
|
|
|
82
82
|
throw error;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
function recover(state, timeout) {
|
|
86
|
+
if (timeout && state.fatal === timeout) {
|
|
87
|
+
state.fatal = null;
|
|
88
|
+
retry(state, state.epoch);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
85
91
|
export function begin(state) {
|
|
86
92
|
if (state.fatal) { return Promise.reject(state.fatal); }
|
|
87
93
|
if (state.live) { return Promise.resolve(); }
|
|
@@ -89,8 +95,11 @@ export function begin(state) {
|
|
|
89
95
|
if (!state.wanted) { return Promise.resolve(); }
|
|
90
96
|
clearTimeout(state.retry);
|
|
91
97
|
state.retry = null;
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
let timeout;
|
|
99
|
+
const attempt = connect(state, state.epoch);
|
|
100
|
+
void attempt.then(() => { recover(state, timeout); }, () => { recover(state, timeout); });
|
|
101
|
+
state.opening = deadline(attempt, state.options.connectTimeoutMs, 'AMQP connect', (error) => {
|
|
102
|
+
timeout = error; state.fatal = error; state.epoch += 1;
|
|
94
103
|
}).finally(() => { state.opening = null; });
|
|
95
104
|
return state.opening;
|
|
96
105
|
}
|