You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
util: fix inspection of errors with tampered stack property for node v10 #33948
This is an error report for node v10 which has already been fixed for node v12 and may make sense to fix in node v10 as well. The fix in node v12 could have been made via pull request #30576 .
Version: 10.21.0
Platform: Mac OS X
Subsystem: util
What steps will reproduce the bug?
'use strict'letutil=require('util')leterr1=newError()leterr2=newError()err2.stack=String(err2.stack).split('\n')// This breaks it.util.inspect(err1)// -> OKutil.inspect(err2)// -> OKutil.inspect({ err1 })// -> OKutil.inspect({ err2 })// -> TypeError: formatError(...).replace is not a function
How often does it reproduce? Is there a required condition?
Every time in node v10.21.0. Never in node v12.16.1.
What is the expected behavior?
The err2.stack array is inspected as an array would usually be inspected.
What do you see instead?
util.inspect({ err2 }) throws this error: TypeError: formatError(...).replace is not a function
Additional information
Feel free to close if such a fix is not within the scope of the LTS maintenance phase in which node v10 is currently in.
@ZYSzys#26923 should not be backported. The actual fix is to change the formatError function as it is in v10 to return value.stack ? String(value.stack) : errorToString(value);
Activity
ZYSzys commentedon Jun 21, 2020
/cc @nodejs/release, maybe we could backport #30576 to next v10 LTS release.
richardlau commentedon Jul 2, 2020
#30576 doesn't land cleanly on v10.x-staging so would need a manual backport.
ZYSzys commentedon Jul 3, 2020
However, I found if we want to land #30576, we need to land #26923 first, which was marked as
dont-land-on-v10.x./cc @BridgeAR
BridgeAR commentedon Jul 3, 2020
@ZYSzys #26923 should not be backported. The actual fix is to change the
formatErrorfunction as it is in v10 toreturn value.stack ? String(value.stack) : errorToString(value);BridgeAR commentedon Mar 19, 2021
I am closing this as it's not a security issue and Node.js 10 is soon not maintained anymore.
@analog-nico I hope you were able to move to Node.js 12 or above by now!
analog-nico commentedon Mar 21, 2021
@BridgeAR Sounds good! I made sure to not run into this issue in my code and upgrading node makes sense anyways. Thanks!