0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-04-07 23:41:43 -05:00

fix: better error handling on Stackblitz (#13484)

* fix: better error handling on Stackblitz

* Remove unused imports
This commit is contained in:
Matt Kane 2025-03-21 14:01:57 +00:00 committed by GitHub
parent e9e9245c7c
commit 8b5e4dc733
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Display useful errors when config loading fails because of Node addons being disabled on Stackblitz

View file

@ -34,6 +34,13 @@ export async function loadConfigWithVite({
const config = await import(pathToFileURL(configPath).toString() + '?t=' + Date.now());
return config.default ?? {};
} catch (e) {
// Normally we silently ignore loading errors here because we'll try loading it again below using Vite
// However, if the error is because of addons being disabled we rethrow it immediately,
// because when this happens in Stackblitz, the Vite error below will be uncatchable
// and we want to provide a more helpful error message.
if (e && typeof e === 'object' && 'code' in e && e.code === 'ERR_DLOPEN_DISABLED') {
throw e;
}
// We do not need to throw the error here as we have a Vite fallback below
debug('Failed to load config with Node', e);
}