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

Cannot convert object to primitive value #285

Closed

Description

@oliviertassinari

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

Activity

  1. LewisJEllis commented on Mar 6, 2017

    @LewisJEllis
    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

  2. LewisJEllis commented on Mar 6, 2017

    @LewisJEllis
    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.

  3. LewisJEllis commented on Mar 7, 2017

    @LewisJEllis
    Contributor

    @oliviertassinari published 1.1.4.

  4. oliviertassinari commented on Mar 7, 2017

    @oliviertassinari
    ContributorAuthor

    @LewisJEllis Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions