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

fix: should not throw error when pass null #99

Merged
merged 1 commit into from Feb 12, 2017
Merged

fix: should not throw error when pass null #99

merged 1 commit into from Feb 12, 2017

Conversation

popomore
Copy link
Member

No description provided.

@@ -80,6 +80,9 @@ class Ready extends EventEmitter {
opt.name = name || cacheKey;
const timer = setTimeout(() => this.emit('ready_timeout', opt.name), opt.timeout);
const cb = once(err => {
if (err != null && !(err instanceof Error)) {
err = new Error(err);
Copy link
Member Author

Choose a reason for hiding this comment

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

improve the stack

Choose a reason for hiding this comment

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

Once err is undefined, this will be broken.

Should be err !== null && err !== undefined instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

err != null is equal to err !== null && err !== undefined

Choose a reason for hiding this comment

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

oh yes. I got wrong.

Copy link

Choose a reason for hiding this comment

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

How about moving this logic to readyDone? So you can deal with error together at one place.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because of the stack, so this way is better rather than after setImmdiate

@popomore popomore mentioned this pull request Feb 12, 2017
4 tasks
@codecov
Copy link

codecov bot commented Feb 12, 2017

Codecov Report

Merging #99 into master will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff          @@
##           master    #99   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          57     57           
=====================================
  Hits           57     57
Impacted Files Coverage Δ
lib/ready.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 18efcbb...c135cac. Read the comment docs.

@shaoshuai0102
Copy link

shaoshuai0102 commented Feb 12, 2017 via email

@fengmk2
Copy link
Member

fengmk2 commented Feb 12, 2017

Going to merge and I will release a patch version.

@fengmk2 fengmk2 merged commit c38468d into master Feb 12, 2017
@fengmk2 fengmk2 deleted the fix branch February 12, 2017 17:12
@fengmk2
Copy link
Member

fengmk2 commented Feb 12, 2017

2.0.1

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.

None yet

3 participants