@zhafron/opencode-kiro-auth 1.4.6 → 1.4.8
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/plugin.js +29 -0
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -253,6 +253,35 @@ export const createKiroPlugin = (id) => async ({ client, directory }) => {
|
|
|
253
253
|
retry++;
|
|
254
254
|
continue;
|
|
255
255
|
}
|
|
256
|
+
if (res.status === 500) {
|
|
257
|
+
acc.failCount = (acc.failCount || 0) + 1;
|
|
258
|
+
let errorMessage = 'Internal Server Error';
|
|
259
|
+
try {
|
|
260
|
+
const errorBody = await res.text();
|
|
261
|
+
const errorData = JSON.parse(errorBody);
|
|
262
|
+
if (errorData.message) {
|
|
263
|
+
errorMessage = errorData.message;
|
|
264
|
+
}
|
|
265
|
+
else if (errorData.Message) {
|
|
266
|
+
errorMessage = errorData.Message;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
// If we can't parse the error, use default message
|
|
271
|
+
}
|
|
272
|
+
if (acc.failCount < 5) {
|
|
273
|
+
const delay = 1000 * Math.pow(2, acc.failCount - 1);
|
|
274
|
+
showToast(`Server Error (500): ${errorMessage}. Retrying in ${Math.ceil(delay / 1000)}s...`, 'warning');
|
|
275
|
+
await sleep(delay);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
am.markUnhealthy(acc, `Server Error (500) after 5 attempts: ${errorMessage}`);
|
|
280
|
+
await am.saveToDisk();
|
|
281
|
+
showToast(`Server Error (500): ${errorMessage}. Marking account as unhealthy and switching...`, 'warning');
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
256
285
|
if (res.status === 429) {
|
|
257
286
|
const w = parseInt(res.headers.get('retry-after') || '60') * 1000;
|
|
258
287
|
am.markRateLimited(acc, w);
|