mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
Bugfix: handle unawaited promise (#176)
This commit is contained in:
parent
b81abd5b2c
commit
95b1733c89
2 changed files with 23 additions and 16 deletions
5
.changeset/khaki-bags-brake.md
Normal file
5
.changeset/khaki-bags-brake.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix: wait for async operation to finish
|
|
@ -169,7 +169,7 @@ const defaultExtensions: Readonly<Record<string, ValidExtensionPlugins>> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Gather necessary framework runtimes (React, Vue, Svelte, etc.) for dynamic components */
|
/** Gather necessary framework runtimes (React, Vue, Svelte, etc.) for dynamic components */
|
||||||
async function gatherRuntimes({ astroConfig, buildState, filepath, logging, resolvePackageUrl, mode, runtime }: PageBuildOptions) {
|
async function gatherRuntimes({ astroConfig, buildState, filepath, logging, resolvePackageUrl, mode, runtime }: PageBuildOptions): Promise<Set<string>> {
|
||||||
const imports = new Set<string>();
|
const imports = new Set<string>();
|
||||||
|
|
||||||
// Only astro files
|
// Only astro files
|
||||||
|
@ -332,20 +332,22 @@ async function gatherRuntimes({ astroConfig, buildState, filepath, logging, reso
|
||||||
});
|
});
|
||||||
|
|
||||||
// add all imports to build output
|
// add all imports to build output
|
||||||
[...imports].map(async (url) => {
|
await Promise.all(
|
||||||
// don’t end up in an infinite loop building same URLs over and over
|
[...imports].map(async (url) => {
|
||||||
const alreadyBuilt = buildState[url];
|
if (buildState[url]) return; // don’t build already-built URLs
|
||||||
if (alreadyBuilt) return;
|
|
||||||
|
|
||||||
// add new results to buildState
|
// add new results to buildState
|
||||||
const result = await runtime.load(url);
|
const result = await runtime.load(url);
|
||||||
if (result.statusCode === 200) {
|
if (result.statusCode === 200) {
|
||||||
buildState[url] = {
|
buildState[url] = {
|
||||||
srcPath: filepath,
|
srcPath: filepath,
|
||||||
contents: result.contents,
|
contents: result.contents,
|
||||||
contentType: result.contentType || mime.getType(url) || '',
|
contentType: result.contentType || mime.getType(url) || '',
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return imports;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue