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(errors): spurious Bluebird warnings #8408

Merged
merged 2 commits into from Oct 4, 2017

Conversation

gabegorelick
Copy link
Contributor

@gabegorelick gabegorelick commented Oct 2, 2017

Pull Request check-list

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions? N/A, unless you think it's worth it
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)? N/A shouldn't modify any API
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

The way Sequelize instantiates some of its Error subclasses confuses Bluebird into thinking that Promises are rejected with non-Error objects, so you get warnings when running with BLUEBIRD_DEBUG enabled.

See petkaantonov/bluebird#990

The way Sequelize instantiates some of its Error subclasses
confuses Bluebird into thinking that Promises are rejected
with non-Error objects.

See petkaantonov/bluebird#990
@@ -11,7 +11,6 @@ class BaseError extends Error {
constructor(message) {
super(message);
this.name = 'SequelizeBaseError';
this.message = message;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The super class should already set this.message = message. The only slight API change is if clients relied on Sequelize's behavior of not defaulting message to '', which Error does.

Note that Sequelize wasn't totally consistent in this regard, since ValidationErrorItem.message defaulted to ''.

Copy link
Contributor

Choose a reason for hiding this comment

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

ECMAScript specs says error messages should default to empty string where we are setting them to undefined.

Bluebird's error check also conforms to this, but it would be better if they also include instance of check as undefined error message very much is possible in everyday code.

@codecov
Copy link

codecov bot commented Oct 2, 2017

Codecov Report

Merging #8408 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Copy link
Contributor

@sushantdhiman sushantdhiman left a comment

Choose a reason for hiding this comment

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

LGTM

@sushantdhiman sushantdhiman requested a review from a team October 3, 2017 04:29
@janmeier janmeier merged commit ea8e631 into sequelize:master Oct 4, 2017
@gabegorelick gabegorelick deleted the bluebird-warnings branch October 17, 2017 15:08
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