Skip to content

Conversation

atian25
Copy link
Member

@atian25 atian25 commented Oct 19, 2020

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change
  • 仅在启动成功后禁止新增 timing,不清理启动的 timing,让一些采集 timing 的插件有机会获取
  • 12.19 的 keep-alive 处理

@atian25 atian25 requested review from killagu and mansonchor October 19, 2020 06:51
@atian25 atian25 changed the title fix: defer clear timing fix: defer clear timing && skip keep-alive >12.19.0 Oct 19, 2020
@atian25 atian25 changed the title fix: defer clear timing && skip keep-alive >12.19.0 fix: defer clear timing && skip keep-alive after 12.19.0 Oct 19, 2020
@atian25 atian25 force-pushed the delay-clear-timing branch 3 times, most recently from c071c77 to 76ddf1a Compare October 19, 2020 07:33
// 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('>=14.8.0 || ^12.19.0');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提了个 PR 给 node:nodejs/node#35623

Copy link
Member Author

@atian25 atian25 Oct 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有一个隐藏问题(14.8.0 和 12.19.0 有一个 floor 的 bug),但没有完美解。

如果用户设置为 12001,且 Node 是 14.8.0 的话,会出现 2 种情况:

  1. keep-alive 被同时设置为 2 个值: timeout=12.001, timeout=12
  2. keep-alive 只被设置为:timeout=12.001

此处选择了后者,因为一般不会设置为非标准值。

lib/egg.js Outdated
fs.writeFileSync(dumpFile, CircularJSON.stringify(json, null, 2));
this.timing.clear();
this.timing.disable();
setTimeout(() => this.timing.clear(), 3000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这么加不太行,如果 agent 在 serverDidReady 里去读取,很有可能是读不到的。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3s 还不够?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要不要考虑加个选项...把内存保留回来

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appserver 启动很多不止 3s 的。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那还是改为默认不清理吧,只是 disable 禁止新增

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改了,再看下

@atian25 atian25 force-pushed the delay-clear-timing branch 3 times, most recently from b2b6b35 to 5ce9dd3 Compare October 19, 2020 07:50
@atian25 atian25 force-pushed the delay-clear-timing branch from 5ce9dd3 to f8dc6c6 Compare October 19, 2020 07:53
@atian25 atian25 changed the title fix: defer clear timing && skip keep-alive after 12.19.0 fix: remove clear timing && skip keep-alive after 12.19.0 Oct 19, 2020
@codecov
Copy link

codecov bot commented Oct 19, 2020

Codecov Report

Merging #4497 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #4497   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           34        34           
  Lines         1113      1112    -1     
  Branches       183       183           
=========================================
- Hits          1113      1112    -1     
Impacted Files Coverage Δ
lib/egg.js 100.00% <ø> (ø)
app/middleware/meta.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 773df78...f8dc6c6. Read the comment docs.

Copy link
Contributor

@killagu killagu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atian25 atian25 merged commit 9f653af into master Oct 19, 2020
@atian25 atian25 deleted the delay-clear-timing branch October 19, 2020 09:20
popomore pushed a commit that referenced this pull request Oct 19, 2020
fix: remove clear timing && skip keep-alive after 12.19.0 (#4497)
qingdengyue pushed a commit to VioletLife/egg that referenced this pull request Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants