Skip to content

Commit

Permalink
fix: remove clear timing && skip keep-alive after 12.19.0 (#4497)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored Oct 19, 2020
1 parent 773df78 commit 9f653af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/middleware/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
const semver = require('semver');

module.exports = options => {
// Node.js >=14.8.0 will set Keep-Alive Header, see https://github.com/nodejs/node/pull/34561
const shouldPatchKeepAliveHeader = semver.lt(process.version, '14.8.0');
// Node.js >=14.8.0 and >= 12.19.0 will set Keep-Alive Header, see https://github.com/nodejs/node/pull/34561
const shouldPatchKeepAliveHeader = !semver.satisfies(process.version, '>=14.8.0 || ^12.19.0');

return async function meta(ctx, next) {
if (options.logging) {
Expand Down
2 changes: 1 addition & 1 deletion lib/egg.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,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(json, null, 2));
this.timing.clear();
// only disable, not clear bootstrap timing data.
this.timing.disable();
} catch (err) {
this.coreLogger.warn(`dumpTiming error: ${err.message}`);
Expand Down
6 changes: 3 additions & 3 deletions test/lib/egg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ describe('test/lib/egg.test.js', () => {
assert(json[0].pid === process.pid);
});

it('should disable & clear timing after ready', function* () {
it('should disable timing after ready', function* () {
const json = app.timing.toJSON();
assert(json.length === 0);
const last = json[json.length - 1];
app.timing.start('a');
app.timing.end('a');
const json2 = app.timing.toJSON();
assert(json2.length === 0);
assert(json2[json.length - 1].name === last.name);
});

it('should ignore error when dumpTiming', done => {
Expand Down

0 comments on commit 9f653af

Please sign in to comment.