Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-create-astro-registry-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Fixes a hang that could occur when the npm registry is slow or unresponsive by adding a 10 second timeout to the version check
9 changes: 8 additions & 1 deletion packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ export const getVersion = (
let registry = await getRegistry(packageManager);
const { version } = await fetch(`${registry}/${packageName}/${packageTag}`, {
redirect: 'follow',
signal: AbortSignal.timeout(10_000),
})
.then((res) => res.json())
.catch(() => ({ version: fallback }));
.catch(() => {
const fallbackName = fallback || `'latest'`;
console.warn(
`Unable to fetch latest ${packageName} version from the npm registry. Using ${fallbackName} instead.`,
);
return { version: fallback };
});
return resolve(version);
});

Expand Down