-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Why did startStackFunction
get renamed to startStackFn
from 8.x to 10.x
#27671
Comments
@Raynos that was a mistake on my side. I did not anticipate that the error class would actually really be used in the wild (it was not documented) and that this option would be used. I'll open a PR to accept both as valid options but that will probably not help a lot anymore. |
This makes sure the `AssertionError` still accepts the `stackStartFunction` option as alternative to the `stackStartFn`. Fixes: nodejs#27671
I'll try to backport this as well. |
@BridgeAR you are my hero. Here is my use case for context.
I want to use I'll open an issue / PR on node core for this seperately as it's a useful issue that came up on twitter a while ago. |
@Raynos I believe you actually want to use the |
An easier solution would also be the following: 'use strict'
const process = require('process')
const assert = require('assert').strict
module.exports = nextTickAssert
function nextTickAssert (value, message) {
try {
assert(value, message)
} catch (err) {
Error.captureStackTrace(err, nextTickAssert);
process.nextTick(() => {
throw err
})
}
} |
Your solution means i don't have an issue with the I'd have to write some benchmarks though. The existing |
@Raynos the cost should be identical in newer Node.js versions. I believe Node.js 8 is already fine with There is one significant difference between these two versions though: the error message will be different (in case no |
This makes sure the `AssertionError` still accepts the `stackStartFunction` option as alternative to the `stackStartFn`. PR-URL: #27672 Fixes: #27671 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
In
assert.AssertionError
, for some reasonoptions.startStackFunction
got renamed tooptions.startStackFn
from v8.x to v10.xThis means you have to do
var e = new AssertionError({ startStackFn: fn, startStackFunction: fn })
to have code that works across both versions of nodejs.This seems like an unnecessary breaking change :( is there no policy or code review for API stability ?
The text was updated successfully, but these errors were encountered: