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:
parent
db5e8ad8af
commit
79d35bbb90
2 changed files with 7 additions and 3 deletions
|
@ -16,9 +16,9 @@ export default function astroIntegrationsContainerPlugin({
|
||||||
}): VitePlugin {
|
}): VitePlugin {
|
||||||
return {
|
return {
|
||||||
name: 'astro:integration-container',
|
name: 'astro:integration-container',
|
||||||
configureServer(server) {
|
async configureServer(server) {
|
||||||
if (server.config.isProduction) return;
|
if (server.config.isProduction) return;
|
||||||
runHookServerSetup({ config: settings.config, server, logging });
|
await runHookServerSetup({ config: settings.config, server, logging });
|
||||||
},
|
},
|
||||||
async buildStart() {
|
async buildStart() {
|
||||||
if (settings.injectedRoutes.length === settings.resolvedInjectedRoutes.length) return;
|
if (settings.injectedRoutes.length === settings.resolvedInjectedRoutes.length) return;
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
import { setTimeout } from "node:timers/promises";
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
return {
|
return {
|
||||||
name: '@astrojs/test-integration',
|
name: '@astrojs/test-integration',
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:server:setup': ({ server }) => {
|
'astro:server:setup': async ({ server }) => {
|
||||||
|
// Ensure that `async` is respected
|
||||||
|
await setTimeout(100);
|
||||||
server.middlewares.use(
|
server.middlewares.use(
|
||||||
function middleware(req, res, next) {
|
function middleware(req, res, next) {
|
||||||
res.setHeader('x-middleware', 'true');
|
res.setHeader('x-middleware', 'true');
|
||||||
|
|
Loading…
Reference in a new issue