@atolis-hq/wake 0.4.79 → 0.4.80
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.
|
@@ -124,6 +124,6 @@ export function resolveWakeVersion(options = {}) {
|
|
|
124
124
|
return `g${headHash.slice(0, 7)}`;
|
|
125
125
|
return '0.1.0-dev';
|
|
126
126
|
}
|
|
127
|
-
export const wakeVersion = "v0.4.
|
|
127
|
+
export const wakeVersion = "v0.4.80";
|
|
128
128
|
/** The registry-installable version used by packaged sandbox images. */
|
|
129
129
|
export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
|
|
@@ -65,7 +65,7 @@ class CoordinatedGitHubRequests {
|
|
|
65
65
|
}
|
|
66
66
|
recordFailure(error) {
|
|
67
67
|
const retryAfterMs = retryAfterMilliseconds(error, this.now());
|
|
68
|
-
if (
|
|
68
|
+
if (isRateLimited(error)) {
|
|
69
69
|
this.cooldownUntil = this.now() + (retryAfterMs ?? 60_000);
|
|
70
70
|
this.transientFailureCount = 0;
|
|
71
71
|
return;
|
|
@@ -82,6 +82,18 @@ function statusOf(error) {
|
|
|
82
82
|
return undefined;
|
|
83
83
|
return typeof error.status === 'number' ? error.status : undefined;
|
|
84
84
|
}
|
|
85
|
+
// Secondary rate limits arrive as 403, not 429; a plain permission 403 must not cool down.
|
|
86
|
+
function isRateLimited(error) {
|
|
87
|
+
const status = statusOf(error);
|
|
88
|
+
if (status === 429)
|
|
89
|
+
return true;
|
|
90
|
+
if (status !== 403)
|
|
91
|
+
return false;
|
|
92
|
+
const headers = responseHeaders(error);
|
|
93
|
+
return (headerValue(headers, 'retry-after') !== undefined ||
|
|
94
|
+
headerValue(headers, 'x-ratelimit-remaining') === '0' ||
|
|
95
|
+
(error instanceof Error && /rate limit/i.test(error.message)));
|
|
96
|
+
}
|
|
85
97
|
function isTransient(error) {
|
|
86
98
|
const status = statusOf(error);
|
|
87
99
|
if (status !== undefined)
|
|
@@ -103,21 +115,23 @@ function retryAfterMilliseconds(error, now) {
|
|
|
103
115
|
return Number.isFinite(timestamp) ? Math.max(0, timestamp - now) : undefined;
|
|
104
116
|
}
|
|
105
117
|
function retryAfterValue(error) {
|
|
118
|
+
return headerValue(responseHeaders(error), 'retry-after');
|
|
119
|
+
}
|
|
120
|
+
function responseHeaders(error) {
|
|
106
121
|
if (typeof error !== 'object' || error === null || !('response' in error))
|
|
107
122
|
return undefined;
|
|
108
123
|
const response = error.response;
|
|
109
124
|
if (typeof response !== 'object' || response === null || !('headers' in response))
|
|
110
125
|
return undefined;
|
|
111
|
-
return
|
|
126
|
+
return response.headers;
|
|
112
127
|
}
|
|
113
|
-
function headerValue(headers) {
|
|
128
|
+
function headerValue(headers, name) {
|
|
114
129
|
if (typeof headers !== 'object' || headers === null)
|
|
115
130
|
return undefined;
|
|
116
131
|
if ('get' in headers && typeof headers.get === 'function') {
|
|
117
|
-
const value = headers.get(
|
|
132
|
+
const value = headers.get(name);
|
|
118
133
|
return typeof value === 'string' ? value : undefined;
|
|
119
134
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return undefined;
|
|
135
|
+
const value = headers[name];
|
|
136
|
+
return typeof value === 'string' ? value : undefined;
|
|
123
137
|
}
|