question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot convert object to primitive value

See original GitHub issue

This is similar to https://github.com/emberjs/ember.js/issues/14187, but I have a reproduction in Ember 2.10 with no addons:

https://ember-twiddle.com/4df2d62bf5f1c05bd74086dc79326020?openFiles=components.my-component.js%2C

The critical ingredient seems to be that I am taking an object created by the hash helper, putting it inside an Array, and passing the array into another component. When such an array hits toString it causes an exception.

(It’s hitting toString in the first place to support an assertion.)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:10
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iStefocommented, Jan 27, 2017

I have a similar problem when passing a hash into the array helper from https://github.com/DockYard/ember-composable-helpers.

Twiddle that reproduces the issue (note how myComponent.totalLength can’t be computed!): https://ember-twiddle.com/b886a7c23774720188df41e9967aa443?openFiles=templates.application.hbs%2C

“Fixed” by replacing the hash helper with a very simple my-hash helper that returns a full object instead of the EmptyObject that Ember itself uses: (note how now totalLength is shown): https://ember-twiddle.com/208688934ca9599e8607045d3e067fde?openFiles=templates.application.hbs%2C

Edit: The problem occurs in 2.10.2 but also in 2.11 (which is not available in Twiddle)

0reactions
rwjbluecommented, Feb 24, 2017

@gabrielgrant / @caseklim - Good spot, I didn’t notice that both were describing the same issue. I’ll close #14922 for now and we can track the issue here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot convert object to primitive value - Stack Overflow
most of the Javascript objects have toString() method inherited from Object.prototype . but some of them that have a null prototype , not...
Read more >
Object to primitive conversion - The Modern JavaScript Tutorial
These methods must return a primitive value. If toString or valueOf returns an object, then it's ignored (same as if there were no...
Read more >
Cannot convert object to primitive value · Issue #309 - GitHub
In almanac you have debug lines like this: (0, _debug2.default)('almanac::constructor initialized runtime fact:' + fact.id + ' with ' + fact.value + '<'...
Read more >
typeerror: cannot convert object to primitive value - You.com
Cannot convert object to primitive value error in react application? ... It is a breaking change that affects many plugins. Temporarily reverting to...
Read more >
Cannot convert object to primitive value | The Node.js Master ...
Your browser can't play this video. ... Bonus Lecture - TypeError: Cannot convert object to primitive value | The Node.js Master Class.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found