gencow 0.1.205 → 0.1.206
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/lib/release-client.mjs
CHANGED
|
@@ -75,11 +75,11 @@ async function responseError(response, fallback, creds, parsedBody) {
|
|
|
75
75
|
throwResponseError(response, fallback, body, creds);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
async function releaseCapability({ creds, appId, environment, platformFetchImpl }) {
|
|
78
|
+
async function releaseCapability({ creds, appId, environment, platformFetchImpl, signal }) {
|
|
79
79
|
const response = await platformFetchImpl(
|
|
80
80
|
creds,
|
|
81
81
|
`/platform/apps/${appId}/release-capability?environment=${environment}`,
|
|
82
|
-
{ method: "GET" },
|
|
82
|
+
{ method: "GET", ...(signal ? { signal } : {}) },
|
|
83
83
|
);
|
|
84
84
|
if (response.status === 404 || response.status === 405) {
|
|
85
85
|
const body = (await response.json().catch(() => ({}))) || {};
|
|
@@ -108,8 +108,41 @@ export async function prepareReleaseAttempt({
|
|
|
108
108
|
createReleaseSourcePackageImpl = createReleaseSourcePackage,
|
|
109
109
|
platformFetchImpl = platformFetch,
|
|
110
110
|
unlinkImpl = unlink,
|
|
111
|
+
capabilityTimeoutMs = null,
|
|
112
|
+
allowCapabilityTimeoutFallback = false,
|
|
113
|
+
capabilityTimeoutSetTimeoutImpl = setTimeout,
|
|
114
|
+
capabilityTimeoutClearTimeoutImpl = clearTimeout,
|
|
111
115
|
}) {
|
|
112
|
-
const
|
|
116
|
+
const capabilityRequest = (signal) => releaseCapability({ creds, appId, environment, platformFetchImpl, signal });
|
|
117
|
+
let capability;
|
|
118
|
+
if (Number.isFinite(capabilityTimeoutMs) && capabilityTimeoutMs > 0) {
|
|
119
|
+
let timeout;
|
|
120
|
+
const controller = new AbortController();
|
|
121
|
+
try {
|
|
122
|
+
capability = await Promise.race([
|
|
123
|
+
capabilityRequest(controller.signal),
|
|
124
|
+
new Promise((_, reject) => {
|
|
125
|
+
timeout = capabilityTimeoutSetTimeoutImpl(
|
|
126
|
+
() => {
|
|
127
|
+
controller.abort();
|
|
128
|
+
reject(new Error("APP_RELEASE_CAPABILITY_TIMEOUT"));
|
|
129
|
+
},
|
|
130
|
+
capabilityTimeoutMs,
|
|
131
|
+
);
|
|
132
|
+
timeout?.unref?.();
|
|
133
|
+
}),
|
|
134
|
+
]);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (!(allowCapabilityTimeoutFallback && error?.message === "APP_RELEASE_CAPABILITY_TIMEOUT")) {
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
capability = null;
|
|
140
|
+
} finally {
|
|
141
|
+
if (timeout !== undefined) capabilityTimeoutClearTimeoutImpl(timeout);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
capability = await capabilityRequest();
|
|
145
|
+
}
|
|
113
146
|
if (!capability) return null;
|
|
114
147
|
const requestId = releaseRequestId(explicitRequestId);
|
|
115
148
|
const sourcePackage = await createReleaseSourcePackageImpl({
|
|
@@ -304,6 +304,8 @@ export function createStaticDeployRuntime({
|
|
|
304
304
|
environment: opts.envTarget || "dev",
|
|
305
305
|
requestId: opts.requestId || null,
|
|
306
306
|
platformFetchImpl,
|
|
307
|
+
capabilityTimeoutMs: 15_000,
|
|
308
|
+
allowCapabilityTimeoutFallback: true,
|
|
307
309
|
});
|
|
308
310
|
releaseAttemptId = releaseAttempt?.attemptId ?? null;
|
|
309
311
|
}
|