Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Cannot convert object to primitive value #285

Closed
oliviertassinari opened this issue Mar 5, 2017 · 4 comments
Closed

Cannot convert object to primitive value #285

oliviertassinari opened this issue Mar 5, 2017 · 4 comments

Comments

@oliviertassinari
Copy link
Contributor

I have got the following error message coming from raven-node:

TypeError: Cannot convert object to primitive value
at Array.join (native)
at Console.log (/Users/oliviertassinari/argos/node_modules/raven/lib/breadcrumbs.js:38:31)
at resolveSetValidationStatus (/Users/oliviertassinari/argos/src/server/graphql/BuildType.js:64:11)
at resolveOrError (/Users/oliviertassinari/argos/node_modules/graphql/execution/execute.js:474:12)
at resolveField (/Users/oliviertassinari/argos/node_modules/graphql/execution/execute.js:460:16)
at /Users/oliviertassinari/argos/node_modules/graphql/execution/execute.js:248:20
at process._tickDomainCallback (internal/process/next_tick.js:129:7)

It's coming from that line.
Here is a reproduction example to better understand what's going on:

var args = [];
var hash = Object.create(null);
args.push(hash);
args.join(' ') // Cannot convert object to primitive value
@LewisJEllis
Copy link
Contributor

Oh, fun stuff; thanks for the report @oliviertassinari. Not the first time an object without a prototype has been tricky (see also here with query_string).

This is probably broken in raven-js as well, and it's not immediately obvious to me what the best strategy for a fix is; at the very least we can avoid creating this TypeError, but I've also noticed that '' + args.join(' ') doesn't always produce the same string that the native console methods will actually log.

/cc @benvinegar let's chat on this

@LewisJEllis
Copy link
Contributor

Investigated more, figured out we should be using util.format. Fairly easy fix on the node side, opening a separate issue for the browser JS side where we don't have util.format.

Will have 1.1.4 out shortly.

@LewisJEllis
Copy link
Contributor

@oliviertassinari published 1.1.4.

@oliviertassinari
Copy link
Contributor Author

@LewisJEllis Thanks for the fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants