Skip to content

Commit

Permalink
fix: initialize nitro app before plugins run (#1906)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <[email protected]>
  • Loading branch information
harlan-zw and pi0 authored Sep 20, 2024
1 parent 1fa2b5e commit 33988d5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/runtime/internal/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,24 @@ function createNitroApp(): NitroApp {
captureError,
};

return app;
}

function runNitroPlugins(nitroApp: NitroApp) {
for (const plugin of plugins) {
try {
plugin(app);
plugin(nitroApp);
} catch (error: any) {
captureError(error, { tags: ["plugin"] });
nitroApp.captureError(error, { tags: ["plugin"] });
throw error;
}
}

return app;
}

export const nitroApp: NitroApp = createNitroApp();

export const useNitroApp = () => nitroApp;
export function useNitroApp() {
return nitroApp;
}

runNitroPlugins(nitroApp);

0 comments on commit 33988d5

Please sign in to comment.