File tree Expand file tree Collapse file tree
extensions/qqbot/src/engine/gateway Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,6 +171,47 @@ describe("dispatchOutbound", () => {
171171 vi . clearAllMocks ( ) ;
172172 } ) ;
173173
174+ it ( "keeps waiting past 300s when a slow provider timeout is configured" , async ( ) => {
175+ vi . useFakeTimers ( ) ;
176+ try {
177+ const runtime = makeRuntime ( {
178+ onDeliver : async ( deliver ) => {
179+ await new Promise < void > ( ( resolve ) => setTimeout ( resolve , 301_000 ) ) ;
180+ await deliver ( { text : "late answer" } , { kind : "block" } ) ;
181+ } ,
182+ } ) ;
183+ let settled = false ;
184+
185+ const dispatchPromise = dispatchOutbound ( makeInbound ( ) , {
186+ runtime,
187+ cfg : {
188+ models : { providers : { ollama : { timeoutSeconds : 1800 } } } ,
189+ } ,
190+ account,
191+ } ) . finally ( ( ) => {
192+ settled = true ;
193+ } ) ;
194+
195+ await vi . advanceTimersByTimeAsync ( 300_000 ) ;
196+
197+ expect ( settled ) . toBe ( false ) ;
198+ expect ( sendTextMock ) . not . toHaveBeenCalled ( ) ;
199+
200+ await vi . advanceTimersByTimeAsync ( 1_000 ) ;
201+ await dispatchPromise ;
202+
203+ expect ( sendTextMock ) . toHaveBeenCalledWith (
204+ expect . anything ( ) ,
205+ "late answer" ,
206+ expect . anything ( ) ,
207+ expect . anything ( ) ,
208+ ) ;
209+ } finally {
210+ vi . clearAllTimers ( ) ;
211+ vi . useRealTimers ( ) ;
212+ }
213+ } ) ;
214+
174215 it ( "marks voice-only inbound as audio without adding voice paths to MediaPaths" , async ( ) => {
175216 let finalized : Record < string , unknown > | undefined ;
176217 const runtime = makeRuntime ( { onFinalize : ( ctx ) => ( finalized = ctx ) } ) ;
You can’t perform that action at this time.
0 commit comments