0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix missing async/await in vite-plugin-integrations-container on astro:server:setup hook (#8104)

* All astro integrations hooks are defined as returning void|Promise, so
all calls need to deal with a possible async/await pattern.  One was
missed in vite-plugin-integrations-container.

This plugin is definitely used by the astro-dev when using a node
adapter, but I am not sure about other such scenarios.  I did a search
through the code base, and all other runHook* calls are properly
awaited.

* chore: make test async

---------

Co-authored-by: Nate Moore <nate@astro.build>
This commit is contained in:
Adam Heath 2023-08-16 12:57:00 -05:00 committed by GitHub
parent db5e8ad8af
commit 79d35bbb90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -16,9 +16,9 @@ export default function astroIntegrationsContainerPlugin({
}): VitePlugin {
return {
name: 'astro:integration-container',
configureServer(server) {
async configureServer(server) {
if (server.config.isProduction) return;
runHookServerSetup({ config: settings.config, server, logging });
await runHookServerSetup({ config: settings.config, server, logging });
},
async buildStart() {
if (settings.injectedRoutes.length === settings.resolvedInjectedRoutes.length) return;

View file

@ -1,8 +1,12 @@
import { setTimeout } from "node:timers/promises";
export default function() {
return {
name: '@astrojs/test-integration',
hooks: {
'astro:server:setup': ({ server }) => {
'astro:server:setup': async ({ server }) => {
// Ensure that `async` is respected
await setTimeout(100);
server.middlewares.use(
function middleware(req, res, next) {
res.setHeader('x-middleware', 'true');