Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Jul 7, 2017

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

@mention-bot
Copy link

@fengmk2, thanks for your PR! By analyzing the history of the files in this pull request, we identified @popomore to be a potential reviewer.

@codecov
Copy link

codecov bot commented Jul 7, 2017

Codecov Report

Merging #1165 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1165      +/-   ##
==========================================
+ Coverage    99.7%   99.71%   +0.01%     
==========================================
  Files          29       29              
  Lines         679      705      +26     
==========================================
+ Hits          677      703      +26     
  Misses          2        2
Impacted Files Coverage Δ
config/config.default.js 100% <ø> (ø) ⬆️
lib/core/httpclient.js 100% <100%> (ø) ⬆️

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 894005c...9227290. Read the comment docs.

@atian25
Copy link
Member

atian25 commented Jul 7, 2017

为什么 3 秒?

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 7, 2017

防止应用设置成小于 30s 的

@atian25
Copy link
Member

atian25 commented Jul 7, 2017

这个是单次请求的超时时间还是?

require('./dnscache_httpclient') : urllib.HttpClient;

const config = app.config.httpclient;
if (typeof config.timeout === 'number' && config.timeout < 30000) {
Copy link
Member

Choose a reason for hiding this comment

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

config.timeout 支持写成 3s 形式的么?

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 12, 2017

@popomore 我改一下,将 httpclient 的配置改成如下

httpclient: {
  // urllib 的全局 options,优先级低于每次请求的 options
  request: { timeout, ... }
  // http agent options
  httpAgent: { ... },
  // https agent options
  httpsAgent: { ... },
}

为了保持兼容性,原来的配置写法统一支持,再下一个 major 版本再 depd。


const config = app.config.httpclient;
if (typeof config.timeout === 'number' && config.timeout < 30000) {
app.coreLogger.warn('[egg:httpclient] config.httpclient.timeout(%s) can\'t below 30000, auto reset to 30000',
Copy link
Member

Choose a reason for hiding this comment

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

逻辑没进来

@gxcsoccer
Copy link
Contributor

可以合了吗?

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 17, 2017

@gxcsoccer 还不行,我得改完

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 17, 2017

依赖 node-modules/urllib#261

@fengmk2 fengmk2 force-pushed the fix-httpclient-timeout branch from 3ed3610 to e0e0b9e Compare July 18, 2017 07:28
@fengmk2
Copy link
Member Author

fengmk2 commented Jul 18, 2017

@gxcsoccer @popomore 可以 review 了,都兼容了,然后区分了。

distinguish options: request, httpAgent and httpsAgent on httpclient
@fengmk2 fengmk2 force-pushed the fix-httpclient-timeout branch from 277263c to 9227290 Compare July 18, 2017 09:38
@fengmk2 fengmk2 merged commit 988b8c8 into master Jul 19, 2017
@fengmk2 fengmk2 deleted the fix-httpclient-timeout branch July 19, 2017 02:05
@fengmk2
Copy link
Member Author

fengmk2 commented Jul 19, 2017

我提个 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants