























@@ -245,6 +245,8 @@ describe("TwilioProvider", () => {
245245const secondInbound = createContext("CallStatus=ringing&Direction=inbound&CallSid=CA222");
246246247247const firstResult = provider.parseWebhookEvent(firstInbound);
248+// Simulate the stream actually connecting (the bug: without this, no activeStreamCalls entry exists)
249+provider.registerCallStream("CA111", "MZ111");
248250const secondResult = provider.parseWebhookEvent(secondInbound);
249251250252expectStreamingTwiml(requireResponseBody(firstResult.providerResponseBody));
@@ -257,6 +259,7 @@ describe("TwilioProvider", () => {
257259const secondInbound = createContext("CallStatus=ringing&Direction=inbound&CallSid=CA322");
258260259261provider.parseWebhookEvent(firstInbound);
262+provider.registerCallStream("CA311", "MZ311");
260263provider.unregisterCallStream("CA311");
261264const secondResult = provider.parseWebhookEvent(secondInbound);
262265@@ -274,6 +277,7 @@ describe("TwilioProvider", () => {
274277const nextInbound = createContext("CallStatus=ringing&Direction=inbound&CallSid=CA422");
275278276279provider.parseWebhookEvent(firstInbound);
280+provider.registerCallStream("CA411", "MZ411");
277281provider.parseWebhookEvent(completed);
278282const nextResult = provider.parseWebhookEvent(nextInbound);
279283@@ -291,6 +295,7 @@ describe("TwilioProvider", () => {
291295const nextInbound = createContext("CallStatus=ringing&Direction=inbound&CallSid=CA522");
292296293297provider.parseWebhookEvent(firstInbound);
298+provider.registerCallStream("CA511", "MZ511");
294299provider.parseWebhookEvent(canceled);
295300const nextResult = provider.parseWebhookEvent(nextInbound);
296301@@ -305,13 +310,31 @@ describe("TwilioProvider", () => {
305310const secondInbound = createContext("CallStatus=ringing&Direction=inbound&CallSid=CA622");
306311307312provider.parseWebhookEvent(firstInbound);
313+provider.registerCallStream("CA611", "MZ611");
308314const result = provider.parseWebhookEvent(secondInbound);
309315310316expect(requireResponseBody(result.providerResponseBody)).toContain(
311317'waitUrl="/voice/hold-music"',
312318);
313319});
314320321+it("does not block subsequent call when first call never opens a media stream", () => {
322+const provider = createProvider();
323+const firstInbound = createContext("CallStatus=ringing&Direction=inbound&CallSid=CA711");
324+const secondInbound = createContext("CallStatus=ringing&Direction=inbound&CallSid=CA722");
325+326+// First call gets streaming TwiML but never connects a media stream
327+// (no registerCallStream ever fires for CA711)
328+provider.parseWebhookEvent(firstInbound);
329+330+// Second inbound call should NOT be queued — no active stream is registered
331+const secondResult = provider.parseWebhookEvent(secondInbound);
332+333+const secondBody = requireResponseBody(secondResult.providerResponseBody);
334+expectStreamingTwiml(secondBody);
335+expect(secondBody).not.toContain("hold-queue");
336+});
337+315338it("uses a stable fallback dedupeKey for identical request payloads", () => {
316339const provider = createProvider();
317340const rawBody = "CallSid=CA789&Direction=inbound&SpeechResult=hello";
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。