@azumag/opencode-rate-limit-fallback 1.0.13 → 1.0.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/dist/index.js +12 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -324,27 +324,18 @@ export const RateLimitFallback = async ({ client, directory }) => {
|
|
|
324
324
|
catch (abortErr) {
|
|
325
325
|
logToFile(`abort failed (non-critical): ${abortErr}`);
|
|
326
326
|
}
|
|
327
|
-
//
|
|
328
|
-
//
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
//
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
catch (promptErr) {
|
|
341
|
-
logToFile(`prompt failed (${promptErr}), falling back to promptAsync`);
|
|
342
|
-
await client.session.promptAsync({
|
|
343
|
-
path: { id: sessionID },
|
|
344
|
-
body: promptBody,
|
|
345
|
-
});
|
|
346
|
-
logToFile(`promptAsync sent successfully for session ${sessionID} with model ${nextModel.providerID}/${nextModel.modelID}`);
|
|
347
|
-
}
|
|
327
|
+
// Wait for abort to fully complete before sending new prompt.
|
|
328
|
+
// Toast alone (~50ms) is insufficient — the abort flag may still be set,
|
|
329
|
+
// causing the new prompt to be immediately interrupted.
|
|
330
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
331
|
+
toast("Retrying", `Using ${nextModel.providerID}/${nextModel.modelID}`, "info").catch(() => { });
|
|
332
|
+
// Use promptAsync — returns immediately, compatible with both TUI and headless modes.
|
|
333
|
+
// prompt (sync) causes race condition: abort flag not yet cleared → prompt interrupted.
|
|
334
|
+
await client.session.promptAsync({
|
|
335
|
+
path: { id: sessionID },
|
|
336
|
+
body: promptBody,
|
|
337
|
+
});
|
|
338
|
+
logToFile(`promptAsync sent successfully for session ${sessionID} with model ${nextModel.providerID}/${nextModel.modelID}`);
|
|
348
339
|
toast("Fallback Successful", `Now using ${nextModel.modelID}`, "success").catch(() => { });
|
|
349
340
|
retryState.delete(stateKey);
|
|
350
341
|
// Clear fallback flag to allow next fallback if needed
|
package/package.json
CHANGED