Merge pull request 'Tests: fix two CI flakes seen on main' (#68) from test-flakes into main
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Successful in 32s
CI / Lint (eslint) (push) Successful in 36s
CI / Security (npm audit) (push) Successful in 17s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m40s
CI / Integration (api) (push) Successful in 3m18s
CI / UI (playwright) (push) Successful in 3m6s
CI / Deploy (push) Successful in 15s
CI / Deploy worker (push) Successful in 7s
CI / Notify (push) Successful in 4s
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Successful in 32s
CI / Lint (eslint) (push) Successful in 36s
CI / Security (npm audit) (push) Successful in 17s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m40s
CI / Integration (api) (push) Successful in 3m18s
CI / UI (playwright) (push) Successful in 3m6s
CI / Deploy (push) Successful in 15s
CI / Deploy worker (push) Successful in 7s
CI / Notify (push) Successful in 4s
This commit was merged in pull request #68.
This commit is contained in:
commit
93b1422300
2 files changed
+17
-3
No files matched your search
@@ -18,11 +18,22 @@ const SSO = {
|
||||
};
|
||||
|
||||
async function api(method, url, { headers = {}, body } = {}) {
|
||||
const res = await fetch(BASE + url, {
|
||||
const send = () => fetch(BASE + url, {
|
||||
method,
|
||||
headers: { ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}), ...headers },
|
||||
body: body !== undefined ? JSON.stringify(body) : undefined,
|
||||
});
|
||||
let res;
|
||||
try {
|
||||
res = await send();
|
||||
} catch (e) {
|
||||
// A pooled keep-alive connection can be closed by the server (5 s idle timeout) just
|
||||
// as the client reuses it: ECONNRESET. Retry once, but only reads; a write might
|
||||
// already have taken effect.
|
||||
const reset = e && e.cause && e.cause.code === 'ECONNRESET';
|
||||
if (method !== 'GET' || !reset) throw e;
|
||||
res = await send();
|
||||
}
|
||||
const text = await res.text();
|
||||
let json = null;
|
||||
try { json = JSON.parse(text); } catch { /* not JSON */ }
|
||||
|
||||
Reference in new issue
Block a user