@wu529778790/open-im 1.9.1 → 1.9.2
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/dist/index.js +7 -0
- package/dist/workbuddy/centrifuge-client.js +18 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -289,6 +289,13 @@ export async function main() {
|
|
|
289
289
|
log.error("Unhandled Promise rejection:", reason);
|
|
290
290
|
});
|
|
291
291
|
process.on("uncaughtException", (err) => {
|
|
292
|
+
const msg = err?.message ?? String(err);
|
|
293
|
+
// WebSocket "not open" errors are transient — the connection will auto-reconnect.
|
|
294
|
+
// Exiting would take down all platforms, so just log and continue.
|
|
295
|
+
if (msg.includes("WebSocket is not open") || msg.includes("readyState")) {
|
|
296
|
+
log.warn("Transient WebSocket error (ignored, will reconnect):", err);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
292
299
|
log.error("Uncaught exception (process will exit):", err);
|
|
293
300
|
closeLogger();
|
|
294
301
|
process.exit(1);
|
|
@@ -259,17 +259,29 @@ export class WorkBuddyCentrifugeClient {
|
|
|
259
259
|
payload,
|
|
260
260
|
};
|
|
261
261
|
try {
|
|
262
|
+
// Guard against the race where WebSocket transitions to CONNECTING between
|
|
263
|
+
// the state check above and the actual publish call.
|
|
262
264
|
this.client.publish(this.config.channel, envelope).catch((err) => {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
266
|
+
if (msg.includes('WebSocket is not open') || msg.includes('readyState')) {
|
|
267
|
+
log.warn(`${this.logPrefix} WebSocket not ready for send (will reconnect): ${msg}`);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
log.error(`${this.logPrefix} Message send failed:`, err);
|
|
271
|
+
this.callbacks.onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
272
|
+
}
|
|
265
273
|
});
|
|
266
|
-
const json = JSON.stringify(envelope);
|
|
267
|
-
const preview = json.length > 500 ? json.substring(0, 500) + `...(truncated)` : json;
|
|
268
274
|
log.debug(`${this.logPrefix} Sent message: method=${method}, msg_id=${envelope.msg_id}`);
|
|
269
275
|
}
|
|
270
276
|
catch (error) {
|
|
271
|
-
|
|
272
|
-
|
|
277
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
278
|
+
if (msg.includes('WebSocket is not open') || msg.includes('readyState')) {
|
|
279
|
+
log.warn(`${this.logPrefix} WebSocket not ready for send (will reconnect): ${msg}`);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
log.error(`${this.logPrefix} Message send failed:`, error);
|
|
283
|
+
this.callbacks.onError?.(error instanceof Error ? error : new Error(`Message send failed: ${msg}`));
|
|
284
|
+
}
|
|
273
285
|
}
|
|
274
286
|
}
|
|
275
287
|
/**
|