From b7b717f8db9000d813a09155f6ec3d4a6ec0c9f2 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Fri, 13 Jan 2023 23:37:23 +0800 Subject: [PATCH 1/3] feat: log app start timeline on coreLogger https://github.com/eggjs/egg-core/pull/260 --- lib/egg.js | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/egg.js b/lib/egg.js index a33b451a6b..8f94698bd5 100644 --- a/lib/egg.js +++ b/lib/egg.js @@ -417,6 +417,7 @@ class EggApplication extends EggCore { const rundir = this.config.rundir; const dumpFile = path.join(rundir, `${this.type}_timing_${process.pid}.json`); fs.writeFileSync(dumpFile, CircularJSON.stringify(items, null, 2)); + this.coreLogger.info(this.timing.toString()); // only disable, not clear bootstrap timing data. this.timing.disable(); // show duration >= ${slowBootActionMinDuration}ms action to warnning log @@ -437,10 +438,11 @@ class EggApplication extends EggCore { _setupTimeoutTimer() { const startTimeoutTimer = setTimeout(() => { + this.coreLogger.error(this.timing.toString()); this.coreLogger.error(`${this.type} still doesn't ready after ${this.config.workerStartTimeout} ms.`); // log unfinished - const json = this.timing.toJSON(); - for (const item of json) { + const items = this.timing.toJSON(); + for (const item of items) { if (item.end) continue; this.coreLogger.error(`unfinished timing item: ${CircularJSON.stringify(item)}`); } diff --git a/package.json b/package.json index 204a41ab4e..0776725267 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "delegates": "^1.0.0", "egg-cluster": "^2.0.0", "egg-cookies": "^2.6.1", - "egg-core": "^5.1.1", + "egg-core": "^5.3.0", "egg-development": "^2.7.0", "egg-errors": "^2.3.1", "egg-i18n": "^2.1.1", From b89e09f2f03820ca01ba328347affc4c0dba69dc Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Fri, 13 Jan 2023 23:42:22 +0800 Subject: [PATCH 2/3] f --- lib/egg.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/egg.js b/lib/egg.js index 8f94698bd5..045654a321 100644 --- a/lib/egg.js +++ b/lib/egg.js @@ -422,7 +422,8 @@ class EggApplication extends EggCore { this.timing.disable(); // show duration >= ${slowBootActionMinDuration}ms action to warnning log for (const item of items) { - if (item.duration >= this.config.dump.timing.slowBootActionMinDuration) { + // ignore #0 name: Process Start + if (item.index > 0 && item.duration >= this.config.dump.timing.slowBootActionMinDuration) { this.coreLogger.warn('[egg:core][slow-boot-action] #%d %dms, name: %s', item.index, item.duration, item.name); } From b9240423f746437e565552ec9e311c0ec5533c0e Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Fri, 13 Jan 2023 23:56:48 +0800 Subject: [PATCH 3/3] f --- test/app/middleware/override_method.test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/app/middleware/override_method.test.js b/test/app/middleware/override_method.test.js index 80622e43ff..6037849db9 100644 --- a/test/app/middleware/override_method.test.js +++ b/test/app/middleware/override_method.test.js @@ -1,5 +1,3 @@ -'use strict'; - const utils = require('../../utils'); describe('test/app/middleware/override_method.test.js', () => { @@ -29,6 +27,7 @@ describe('test/app/middleware/override_method.test.js', () => { }); it('should delete', () => { + app.mockCsrf(); return app.httpRequest() .post('/test') .send({ _method: 'DELETE' })