Closed ki4jnq closed 4 months ago
Hi @ki4jnq,
We will see what we can do to actually fix this and get back to you. But for now, a workaround might be to set useHumanStringForObject
to false
in the options object passed to init.
Regards, Taylor
The issue seems to still be present, the object-to-human-string
package didn't really have a new release for 9 years.
I was able to reproduce this in unit tests:
var builder = new MessageBuilder({ useHumanStringForObject: true });
builder.setErrorDetails({ symbol: Symbol("Test") }); // <-- error details has Symbol
var message = builder.build(); // <-- build will fail
And I can see the error:
✖ basic builder tests > humanise Symbol object string > Cannot convert a Symbol value to a string
node_modules/object-to-human-string/lib/index.js
26 if (typeof value[item] === "object" && level < opts.maxLevels) {
27 errorString += opts.separator + item + opts.valueSeparator + "[" + toHumanString(value[item], level + 1, opts) + ']';
28 } else {
29 errorString += opts.separator + item + opts.valueSeparator + value[item];
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
30 }
31 }
32
33 return errorString.substring(opts.separator.length);
type: TypeError
tapCaught: testFunctionThrow
toHumanString (node_modules/object-to-human-string/lib/index.js:29:63)
RaygunMessageBuilder.setErrorDetails (lib/raygun.messageBuilder.ts:131:21)
Test.<anonymous> (test/raygun.messageBuilder_test.js:64:13)
Probably the easier is just to build our own object to human string function.
We attach
Symbol()
type attributes to our known error conditions in our Express application. When Raygun tries to serialize these attributes the following error is raised:It appears that
object-to-human-string
tries to concatenate strings using the+
operator, which specifically throws the above type error. It seems to me that attachingSymbol()
metadata to error objects should not cause an error to be thrown.Thanks for a great tool!