From 4a77268149809830143f2f5f20fadce6e672e424 Mon Sep 17 00:00:00 2001 From: Nick Reese Date: Tue, 8 Mar 2022 17:16:47 +0100 Subject: [PATCH] bug: fix blocking perf bug --- package-lock.json | 2 +- package.json | 2 +- src/Elder.ts | 4 ++-- src/utils/prepareServer.ts | 25 ++++++++++++++----------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9aedb750..cca579e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@elderjs/elderjs", - "version": "1.6.10", + "version": "1.6.11", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d147503b..9a42188d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@elderjs/elderjs", - "version": "1.6.11", + "version": "1.6.12", "main": "./build/index.js", "types": "./build/index.d.ts", "engineStrict": true, diff --git a/src/Elder.ts b/src/Elder.ts index cbc02f19..ae5c86c0 100644 --- a/src/Elder.ts +++ b/src/Elder.ts @@ -349,8 +349,6 @@ class Elder { this.router = prepareRouter(this); this.perf.end(`startup.prepareRouter`); - this.markBootstrapComplete(this); - this.perf.end('startup'); this.perf.stop(); @@ -363,6 +361,8 @@ class Elder { displayPerfTimings([...this.perf.timings]); } } + + this.markBootstrapComplete(this); }); }); } diff --git a/src/utils/prepareServer.ts b/src/utils/prepareServer.ts index 504045ed..c529d9cb 100644 --- a/src/utils/prepareServer.ts +++ b/src/utils/prepareServer.ts @@ -1,17 +1,20 @@ function prepareServer({ bootstrapComplete }) { // eslint-disable-next-line consistent-return return async function prepServer(req, res, next) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { runHook, perf, ...bootstrap } = await bootstrapComplete; - - await runHook('middleware', { - ...bootstrap, - runHook, - req, - next, - res, - request: { type: 'server' }, - }); + try { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { runHook, ...bootstrap } = await bootstrapComplete; + await runHook('middleware', { + ...bootstrap, + runHook, + req, + next, + res, + request: { type: 'server' }, + }); + } catch (e) { + console.error(e); + } }; }