fix: 避免识别异常与支付锁泄漏
修复 ASR 取消后的孤立会话、OCR 表格重复及支付锁无法回收的问题,并补充回归测试。
This commit is contained in:
@@ -146,3 +146,31 @@ test("同一用户的跨连接聊天轮次串行执行", async () => {
|
||||
await Promise.all([first, second]);
|
||||
assert.deepEqual(order, ["first-start", "first-end", "second-start", "second-end"]);
|
||||
});
|
||||
|
||||
test("ASR 解码期间取消后不再创建供应商会话", async () => {
|
||||
const manager = new WebSocketServerManager(0);
|
||||
const ws = createWs();
|
||||
let resolveDecode;
|
||||
const state = {
|
||||
failed: false,
|
||||
session: null,
|
||||
decoder: {
|
||||
rate: 16000,
|
||||
push: () => new Promise((resolve) => { resolveDecode = resolve; }),
|
||||
free() {},
|
||||
},
|
||||
};
|
||||
ws.asrSession = state;
|
||||
let createCalls = 0;
|
||||
manager._createAsrSession = () => {
|
||||
createCalls += 1;
|
||||
return { push() {} };
|
||||
};
|
||||
|
||||
const pending = manager._pushAsrAudio(ws, state, Buffer.from([1]));
|
||||
ws.asrSession = null;
|
||||
resolveDecode(Buffer.alloc(320));
|
||||
await pending;
|
||||
|
||||
assert.equal(createCalls, 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user