@eduardo191labs/opencode-free-pi 0.3.10 → 0.3.11

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.
@@ -153,6 +153,10 @@ const TERMINAL_RETRY_CODES = new Set([
153
153
  ]);
154
154
  const TERMINAL_RETRY_PATTERN = /free usage limit|monthly usage limit|available balance|insufficient_quota|out of budget|quota exceeded|billing|subscription_sharing_usage_limit_exceeded/i;
155
155
  function isTerminalFailure(error) {
156
+ if (error?.type === "aborted" ||
157
+ /aborted|cancelled|canceled|interrupted|AbortError/i.test(`${error?.message ?? ""}`)) {
158
+ return true;
159
+ }
156
160
  const parsed = parseFreePiError(error, true);
157
161
  if (parsed?.code && TERMINAL_RETRY_CODES.has(parsed.code))
158
162
  return true;
@@ -66,6 +66,8 @@ export async function replayConcurrentResponse(deps, event) {
66
66
  const request = event?.request;
67
67
  if (!(original instanceof Response) || !(request instanceof Request))
68
68
  return;
69
+ if (request.signal.aborted)
70
+ return;
69
71
  if (!(await isConcurrent(original)))
70
72
  return;
71
73
  const body = deps.state.replayBodies.get(requestKey(event.sessionID, request)) ??
@@ -80,6 +82,8 @@ export async function replayConcurrentResponse(deps, event) {
80
82
  let previous = request.headers.get("x-session-id") ??
81
83
  wireSessionID(deps, event.sessionID);
82
84
  for (let attempt = 1; attempt <= REPLAY_MAX_ATTEMPTS; attempt++) {
85
+ if (request.signal.aborted)
86
+ return;
83
87
  if (attempt > 1)
84
88
  await sleep(concurrentDelay(attempt));
85
89
  const next = rotateWireSessionID(deps, event.sessionID);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eduardo191labs/opencode-free-pi",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "Ad-supported free-pi provider plugin for OpenCode on Windows, Linux, macOS and Termux",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -236,6 +236,14 @@ const TERMINAL_RETRY_PATTERN =
236
236
  /free usage limit|monthly usage limit|available balance|insufficient_quota|out of budget|quota exceeded|billing|subscription_sharing_usage_limit_exceeded/i;
237
237
 
238
238
  function isTerminalFailure(error: any): boolean {
239
+ if (
240
+ error?.type === "aborted" ||
241
+ /aborted|cancelled|canceled|interrupted|AbortError/i.test(
242
+ `${error?.message ?? ""}`,
243
+ )
244
+ ) {
245
+ return true;
246
+ }
239
247
  const parsed = parseFreePiError(error, true);
240
248
  if (parsed?.code && TERMINAL_RETRY_CODES.has(parsed.code)) return true;
241
249
  const body =
@@ -80,6 +80,7 @@ export async function replayConcurrentResponse(
80
80
  const original = event?.response;
81
81
  const request = event?.request;
82
82
  if (!(original instanceof Response) || !(request instanceof Request)) return;
83
+ if (request.signal.aborted) return;
83
84
  if (!(await isConcurrent(original))) return;
84
85
 
85
86
  const body =
@@ -97,6 +98,7 @@ export async function replayConcurrentResponse(
97
98
  wireSessionID(deps, event.sessionID);
98
99
 
99
100
  for (let attempt = 1; attempt <= REPLAY_MAX_ATTEMPTS; attempt++) {
101
+ if (request.signal.aborted) return;
100
102
  if (attempt > 1) await sleep(concurrentDelay(attempt));
101
103
  const next = rotateWireSessionID(deps, event.sessionID);
102
104
  if (previous && previous !== next) {