Closed
Description
- Version: v7.2.1
- Platform: Darwin Chelan.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
- Subsystem: internal/process/promises.js
Rejecting a promise with a Symbol will crash node. I'd expect it to handle this, or at least to crash in a different way. The traceback indicates node is unable to convert a Symbol to a string, though this is possible both in the REPL and when using .toString()
.
A simple demo session:
$ node
> const s = Symbol()
undefined
> s
Symbol()
> s.toString()
'Symbol()'
> const s2 = Symbol("label")
undefined
> s2
Symbol(label)
> s2.toString()
'Symbol(label)'
> Promise.reject(s2)
Promise { <rejected> Symbol(label) }
> internal/process/promises.js:60
`(rejection id: ${uid}): ${reason}`);
^
TypeError: Cannot convert a Symbol value to a string
at emitWarning (internal/process/promises.js:60:58)
at emitPendingUnhandledRejections (internal/process/promises.js:86:11)
at runMicrotasksCallback (internal/process/next_tick.js:61:9)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
1 ↩