dsh-message-gateway 0.1.13 → 0.1.14
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/lib/index.js +24 -4
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -4635,6 +4635,7 @@ var BridgeManager = class {
|
|
|
4635
4635
|
awaiting = null;
|
|
4636
4636
|
/** 各聊天的独立 agent 会话(key = 平台:chatKey;webhook 固定 'webhook')。 */
|
|
4637
4637
|
agents = /* @__PURE__ */ new Map();
|
|
4638
|
+
disposed = false;
|
|
4638
4639
|
/** 当前语言的文案。 */
|
|
4639
4640
|
t(key) {
|
|
4640
4641
|
return botText(this.config.botLocale, key);
|
|
@@ -4812,14 +4813,32 @@ var BridgeManager = class {
|
|
|
4812
4813
|
console.log("[dsh-message-gateway] chat session reset", { key });
|
|
4813
4814
|
return true;
|
|
4814
4815
|
}
|
|
4815
|
-
/**
|
|
4816
|
+
/** 插件卸载时释放全部聊天会话与长连接(带超时脱钩保护,防死锁)。 */
|
|
4816
4817
|
async dispose() {
|
|
4818
|
+
if (this.disposed) return;
|
|
4819
|
+
this.disposed = true;
|
|
4820
|
+
this.wecom?.stop();
|
|
4821
|
+
this.wecom = null;
|
|
4822
|
+
this.telegram?.stop();
|
|
4823
|
+
this.telegram = null;
|
|
4824
|
+
this.discord?.stop();
|
|
4825
|
+
this.discord = null;
|
|
4826
|
+
this.qq?.stop();
|
|
4827
|
+
this.qq = null;
|
|
4828
|
+
this.email?.stop();
|
|
4829
|
+
this.email = null;
|
|
4817
4830
|
this.finishAllPending();
|
|
4818
4831
|
const entries = [...this.agents.values()];
|
|
4819
4832
|
this.agents.clear();
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4833
|
+
const disposePromises = entries.map(
|
|
4834
|
+
(entry) => entry.dispose().catch((error) => {
|
|
4835
|
+
console.warn("[dsh-message-gateway] agent dispose warning", String(error));
|
|
4836
|
+
})
|
|
4837
|
+
);
|
|
4838
|
+
await Promise.race([
|
|
4839
|
+
Promise.allSettled(disposePromises),
|
|
4840
|
+
new Promise((resolve) => setTimeout(resolve, 1500))
|
|
4841
|
+
]);
|
|
4823
4842
|
}
|
|
4824
4843
|
finishAllPending() {
|
|
4825
4844
|
for (const key of [...this.pendingMap.keys()]) this.finishPending(key);
|
|
@@ -4829,6 +4848,7 @@ var BridgeManager = class {
|
|
|
4829
4848
|
* 回复经 sink 流式回发。所有已打通的平台共用此管线。
|
|
4830
4849
|
*/
|
|
4831
4850
|
async handleExternalMessage(id, rawText) {
|
|
4851
|
+
if (this.disposed) return;
|
|
4832
4852
|
const text = stripMention(rawText);
|
|
4833
4853
|
const reply = (content) => {
|
|
4834
4854
|
id.sink.stream(id.frame, `cmd-${Date.now().toString(36)}`, content, true);
|