| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Replace the `validateFunction()` validator with the `validateCallback()` validator to validate callbacks and keep consistency.
|
Changing an error code is usually semver-major but I could the case for treating this as a bug fix. @nodejs/tsc Thoughts? |
Sorry, something went wrong.
|
Personally, I'd like to see us reduce the specificity of error codes in general. I think ERR_INVALID_ARG_TYPE is fine and we can get rid of ERR_INVALID_CALLBACK entirely. But that would definitely be semver-major and outside the scope of this PR. |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
There was a problem hiding this comment.
This has the potential to break a lot of users' tests when they use queueMicrotask because of the error code change doesn't it?
Intuitively, this sort of breakage isn't worth it in a stable API - it's not a lot of breakage but it's not like we feel strongly the error should change.
(I also agree with @Trott the fact we have a lot of error codes does not necessarily help our users)
Sorry, something went wrong.
|
+1 to label this as semver-major, changing an error code is a potential breaking change. +1 to get rid of ERR_INVALID_CALLBACK in favor of ERR_INVALID_ARG_TYPE at some point. validateCallback is not even checking if the parameter is actually a callback, if you pass a class it won't throw: validateCallback(class{}); // doesn't throw |
Sorry, something went wrong.
Bug fixes can be server-major too, so I'm adding the label back. |
Sorry, something went wrong.
|
I would be more than happy to remove the ERR_INVALID_CALLBACK error entirely and replace it with ERR_INVALID_ARG_TYPE, but wouldn't that still cause error code changes? Since some APIs still seem to be using/throwing the ERR_INVALID_CALLBACK error such as the process.nextTick() method.
validateCallback(class{}); // doesn't throwThat's the exact same case with the validateFunction() validator since both of the validateFunction() and validateCallback() validators have the exact same check, only difference being that they throw a different error. We could entirely remove the validateCallback() validator and the ERR_INVALID_CALLBACK error and replace it with the validateFunction() validator, but we should change the behavior of the validator for it to be able to a differentiate a class and a function, so it would also throw on classes. |
Sorry, something went wrong.
Yes, that would be a semver-major change (but one that is worth making in my opinion, especially if we can remove a few other codes in the same semver-major bump). |
Sorry, something went wrong.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Replace the validateFunction() validator with the
validateCallback() validator to validate callbacks and keep
consistency.