ember-cli-fastboot icon indicating copy to clipboard operation
ember-cli-fastboot copied to clipboard

Ember Runtime Functions not accessible in fastboot mode

Open neeraj-joshi01 opened this issue 8 years ago • 6 comments

Using ember-cli-fastboot with ember v2.4.0, and i am trying to access filterBy method on array and i get the error "arrayName.filterBy is not defined"

neeraj-joshi01 avatar Aug 05 '16 12:08 neeraj-joshi01

This is a known issue. The problem lies around prototype extensions and the fact that objects can be created in contexts outside of the Ember context (due to the way require works with npm). We should have had an issue open for tracking, thank you!

To guess: You have an array that is coming from najax via or something similar?

danmcclain avatar Aug 05 '16 12:08 danmcclain

I have a simple array declared as var filters = [{key: 'Procedure'}] and then I am using filterBy on this array which is not accessible till ember-runtime module gets invoked.

neeraj-joshi01 avatar Aug 05 '16 13:08 neeraj-joshi01

Could you create an example project the exhibits this? The workaround for now would be to use Ember.EnumberableUtils.filterBy for now

danmcclain avatar Aug 05 '16 13:08 danmcclain

It would be great if Ember.A worked while this was broken. Currently it believes that Prototype Extensions work, so the common workaround of wrapping things in an Ember.A fails. I don't think objectAt is available as a util for example

igorT avatar Sep 16 '16 18:09 igorT

Having a similar issue when rendering in fastboot mode in Ember 2.10.0.

When trying to findBy on an array that's an attribute of a DS.Model record:

record.get('categories').findBy('token', params.category)

a TypeError is thrown: Unknown Error: TypeError: record.get(...).findBy is not a function

Wrapping a DS.Model array with Ember.A() doesn't solve anything. However, a manually-declared array inherits Ember.Array methods by default and work as expected.

Is there a workaround for this?

My temp solution is to either implement findBy functionality manually, or do a hard conversion of the DS.Model array to an ember array with const emberArr = JSON.parse(JSON.stringify(record.get('categories'))) and run findBy on it.

sevab avatar Dec 13 '16 15:12 sevab

Having a similar issue when using get(response, 'comments.firstObject'), where response is a result of await fetch -> await response.json() and response.comments is an array.

  • browser: get(response, 'comments.firstObject') // ok
  • fastboot: get(response, 'comments.firstObject') // not ok - undefined
  • fastboot: get(response, 'comments.0') // ok

al3xnag avatar Mar 15 '21 19:03 al3xnag