fix: create new Error instead of mutating in redactToken#2088
Conversation
|
By creating a new error, you lose the original stack trace. According to the spec [1], Error#message should be a writable property. I think an issue must be raised in runtimes that break from the spec. Meanwhile, it might be okay to have a way to opt-out of redaction with an option like dangerouslyLogToken or similar. Thoughts? [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message |
96d01c5 to
be19aee
Compare
|
Thanks for your comment. I just noticed my telegram bot was crashing when encountering this so this was done to avoid that crash. I've updated the fix to preserve it: I think this would be easier for users. |
|
And you've tested that overwriting Error#stack instead of Error#message does not error for you? |
|
Not yet. Give me some time. Sent from my iPhoneOn 11 Apr 2026, at 4:14 PM, Muthu Kumar ***@***.***> wrote:MKRhere left a comment (telegraf/telegraf#2088)
And you've tested that overwriting Error#stack instead of Error#message does not error for you?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
Hi! Upstream is dead since last year, so I've started a community fork telegraf-hardened. I'd love to have your PR there: https://github.com/siakinnik/telegraf-hardened/issues/1 |
Fix issue where redactToken was mutating the original error object and rethrowing it. Now creates a new Error to avoid potential side effects.