Skip to content

Commit

Permalink
feat: log initialization time
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 8, 2024
1 parent e4092d4 commit be0deec
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/runtime/plugin.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ export default <NitroAppPlugin>function (nitroApp) {
nitroApp.hooks.hook("request", async (event) => {
// Lazy initialize proxy when first request comes in
if (!_proxy) {
_proxy = _getPlatformProxy().catch((error) => {
console.error("Failed to initialize wrangler bindings proxy", error);
return _createStubProxy();
});
const start = performance.now();
_proxy = _getPlatformProxy()
.catch((error) => {
console.error("Failed to initialize wrangler bindings proxy", error);
return _createStubProxy();
})
.finally(() => {
const time = Math.round(performance.now() - start);
console.info(`✔ Cloudflare dev proxy took ${time}ms to initialize.`);
});
}

const proxy = await _proxy;
Expand Down

0 comments on commit be0deec

Please sign in to comment.