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:
parent
e9e9245c7c
commit
8b5e4dc733
2 changed files with 12 additions and 0 deletions
5
.changeset/twelve-gifts-attend.md
Normal file
5
.changeset/twelve-gifts-attend.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Display useful errors when config loading fails because of Node addons being disabled on Stackblitz
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue