Skip to content

Commit 8b5e4dc

Browse files
authored
fix: better error handling on Stackblitz (#13484)
* fix: better error handling on Stackblitz * Remove unused imports
1 parent e9e9245 commit 8b5e4dc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.changeset/twelve-gifts-attend.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Display useful errors when config loading fails because of Node addons being disabled on Stackblitz

packages/astro/src/core/config/vite-load.ts

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

0 commit comments

Comments
 (0)