mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-16 05:00:59 +08:00
18 lines
585 B
JavaScript
18 lines
585 B
JavaScript
// Probes the network-failure rejection's CAUSE from package code — the
|
|
// exact consumer shape: provider-utils' handleFetchError classifies
|
|
// retryable network errors by error.cause.message/.code.
|
|
export async function probeRefused(url) {
|
|
try {
|
|
await fetch(url);
|
|
console.log("unexpectedly connected");
|
|
} catch (e) {
|
|
console.log(`err ${e.name}: ${e.message}`);
|
|
const c = e.cause;
|
|
if (c instanceof Error) {
|
|
console.log(`cause ${c.message} code=${c.code} syscall=${c.syscall}`);
|
|
} else {
|
|
console.log(`cause missing: ${String(c)}`);
|
|
}
|
|
}
|
|
}
|