Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use safe-timers to support large delay #19

Merged
merged 2 commits into from
Jun 5, 2017
Merged

Conversation

atian25
Copy link
Member

@atian25 atian25 commented Jun 2, 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

引入 https://github.com/Wizcorp/safe-timers

@atian25 atian25 requested review from popomore and dead-horse June 2, 2017 06:39
@mention-bot
Copy link

@atian25, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fengmk2, @popomore and @dead-horse to be potential reviewers.

@atian25 atian25 requested a review from fengmk2 June 3, 2017 02:05
agent.js Outdated
@@ -3,6 +3,7 @@
const loadSchedule = require('./lib/load_schedule');
const parser = require('cron-parser');
const ms = require('humanize-ms');
const safetimers = require('safe-timers');
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
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

昨天本来想自己写个的,结果发现这个了。

很少人会触到这个阈值吧。

agent.js Outdated
@@ -98,7 +99,7 @@ function startCron(interval, listener) {
nextTick = interval.next().getTime();
} while (now >= nextTick);

setTimeout(() => {
safetimers.setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

只有超过 Math.pow(2, 31) - 1 才使用 safetimers 吧,没超过就使用默认的,这样比较靠谱。

Copy link
Member Author

Choose a reason for hiding this comment

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

改了

@fengmk2
Copy link
Member

fengmk2 commented Jun 3, 2017

Wizcorp/safe-timers#1

@atian25
Copy link
Member Author

atian25 commented Jun 3, 2017

有个测试不太稳定,在 6 下挂了

@codecov
Copy link

codecov bot commented Jun 5, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@4e7bd8a). Click here to learn what that means.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #19   +/-   ##
=========================================
  Coverage          ?   98.21%           
=========================================
  Files             ?        3           
  Lines             ?      112           
  Branches          ?        0           
=========================================
  Hits              ?      110           
  Misses            ?        2           
  Partials          ?        0
Impacted Files Coverage Δ
agent.js 96.55% <80%> (ø)

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 4e7bd8a...6ede778. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 5, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@4e7bd8a). Click here to learn what that means.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #19   +/-   ##
=========================================
  Coverage          ?   98.21%           
=========================================
  Files             ?        3           
  Lines             ?      112           
  Branches          ?        0           
=========================================
  Hits              ?      110           
  Misses            ?        2           
  Partials          ?        0
Impacted Files Coverage Δ
agent.js 96.55% <80%> (ø)

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 4e7bd8a...6ede778. Read the comment docs.

@atian25
Copy link
Member Author

atian25 commented Jun 5, 2017

ci 过了,覆盖率那个是因为 MAX_TIME 没法覆盖。

cc @fengmk2

@dead-horse
Copy link
Member

需要等 safeTimer 的 PR 先合并么?

@atian25
Copy link
Member Author

atian25 commented Jun 5, 2017

那边有 review 需要 @fengmk2 再改改。

感觉不用等吧,那个 PR 是 cov 和 setInterval 的额外参数的,在这个 PR 里面没用到。

@dead-horse dead-horse merged commit 0e1467a into master Jun 5, 2017
@dead-horse dead-horse deleted the safe-timer branch June 5, 2017 04:10
@dead-horse
Copy link
Member

2.4.0

@@ -3,7 +3,8 @@
const loadSchedule = require('./lib/load_schedule');
const parser = require('cron-parser');
const ms = require('humanize-ms');

const safetimers = require('safe-timers');
const MAX_SAFE_TIME = Math.pow(2, 31) - 1;
Copy link
Member

Choose a reason for hiding this comment

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

呃,明明 safetimers 有暴露 maxInterval 出来 https://github.com/Wizcorp/safe-timers/blob/master/index.js ,直接用它的就好

Copy link
Member Author

Choose a reason for hiding this comment

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

#21

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