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.

Uncaught TypeError: Cannot set property 'length' of undefined

See original GitHub issue

Hi thanks for this addon. I’m getting this error with remote pagination.

versions:

ember-cli-pagination: 3.1.3
ember: 3.4.1
ember-data: 3.4.2

route:

import Route from '@ember/routing/route';
import { hash } from 'rsvp';
import RouteMixin from 'ember-cli-pagination/remote/route-mixin';

export default Route.extend(RouteMixin, {
  model(params){
    return hash({
      tracks: this.findPaged('track', params),
      labels: this.store.findAll('label')
    });
  }
});

api response for tracks:

{"tracks":[{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-firedrill-07-15-2017.mp3","podcast_published_date":"2018-03-11T01:37:39.753Z","id":3287,"track_id":2540,"playlist_id":3,"title":"firedrill - 07-15-2017","display_name":"firedrill - 07-15-2017","position":0,"updated_at":"2018-03-11T01:37:39.740Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-firedrill-07-15-2017.mp3?1506488610","labels":[3,4,5,7,26]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-hyperwizard-07-16-2017.mp3","podcast_published_date":"2018-03-11T01:37:38.370Z","id":3286,"track_id":2541,"playlist_id":3,"title":"fuck - hyperwizard - 07-16-2017","display_name":"fuck - hyperwizard - 07-16-2017","position":1,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-hyperwizard-07-16-2017.mp3?1506487921","labels":[18,24]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-hyperwizard-07-16-2017.mp3","podcast_published_date":"2017-07-17T06:44:06.145Z","id":2373,"track_id":2541,"playlist_id":3,"title":"fuck - hyperwizard - 07-16-2017","display_name":"fuck - hyperwizard - 07-16-2017","position":3,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-hyperwizard-07-16-2017.mp3?1506487921","labels":[18,24]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-firedrill-07-15-2017.mp3","podcast_published_date":"2017-07-17T06:13:53.560Z","id":2372,"track_id":2540,"playlist_id":3,"title":"firedrill - 07-15-2017","display_name":"firedrill - 07-15-2017","position":2,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-firedrill-07-15-2017.mp3?1506488610","labels":[3,4,5,7,26]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-ovenrake-07-12-2017.mp3","podcast_published_date":"2017-07-13T02:25:22.053Z","id":2165,"track_id":2281,"playlist_id":3,"title":"ovenrake - good morning datafruits - 07-12-2017","display_name":"ovenrake - good morning datafruits - 07-12-2017","position":4,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-ovenrake-07-12-2017.mp3?1499912924","labels":[1,5,26]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-hyperwizard-07-09-2017.mp3","podcast_published_date":"2017-07-10T15:27:49.446Z","id":2164,"track_id":2280,"playlist_id":3,"title":"hyperwizard - 07-09-2017","display_name":"hyperwizard - 07-09-2017","position":5,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-hyperwizard-07-09-2017.mp3?1499700569","labels":[18,24]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-mixxxgocco-07-09-2017.mp3","podcast_published_date":"2017-07-10T11:30:33.538Z","id":2163,"track_id":2279,"playlist_id":3,"title":"mixxxgocco - 07-09-2017","display_name":"mixxxgocco - 07-09-2017","position":6,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-mixxxgocco-07-09-2017.mp3?1499686274","labels":[8,9,12,13]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-hpcdude-07-08-2017.mp3","podcast_published_date":"2017-07-10T11:30:31.972Z","id":2161,"track_id":2277,"playlist_id":3,"title":"mmainframe - 07-08-2017","display_name":"mmainframe - 07-08-2017","position":7,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-hpcdude-07-08-2017.mp3?1499686122","labels":[2]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-california-games-vrclub-07-08-2017.mp3","podcast_published_date":"2017-07-10T11:26:54.916Z","id":2160,"track_id":2276,"playlist_id":3,"title":"california games - VR CLUB - 07-08-2017","display_name":"california games - VR CLUB - 07-08-2017","position":8,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-california-games-vrclub-07-08-2017.mp3?1499686090","labels":[23]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-mcfiredrill-guest-mix-farragol-07-01-2017.mp3","podcast_published_date":"2017-07-04T02:00:39.822Z","id":2157,"track_id":2274,"playlist_id":3,"title":"firedrill - guest mix FarragoL - 07-01-2017","display_name":"firedrill - guest mix FarragoL - 07-01-2017","position":9,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-mcfiredrill-guest-mix-farragol-07-01-2017.mp3?1499327741","labels":[2,20,21]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-exitpost-07-01-2017.mp3","podcast_published_date":"2017-07-04T01:45:39.026Z","id":2156,"track_id":2273,"playlist_id":3,"title":"Exitpost - 07-01-2017","display_name":"Exitpost - 07-01-2017","position":10,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-exitpost-07-01-2017.mp3?1499327660","labels":[19]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-hyper-06-30-2017.mp3","podcast_published_date":"2017-07-04T01:38:41.510Z","id":2155,"track_id":2271,"playlist_id":3,"title":"hyperwizard - 06-30-2017","display_name":"hyperwizard - 06-30-2017","position":11,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-hyper-06-30-2017.mp3?1499132807","labels":[18]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-wgwn-guestmix-shirtless-06-30-2017.mp3","podcast_published_date":"2017-07-04T01:38:40.380Z","id":2154,"track_id":2272,"playlist_id":3,"title":"wgwn - guestmix shirtless - 06-30-2017","display_name":"wgwn - guestmix shirtless - 06-30-2017","position":12,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-wgwn-guestmix-shirtless-06-30-2017.mp3?1499327783","labels":[3,4,7]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-ovenrake-06-28-2016.mp3","podcast_published_date":"2017-06-29T11:02:19.315Z","id":1946,"track_id":2072,"playlist_id":3,"title":"ovenrake -  good morning datafruits 06-28-2017","display_name":"ovenrake -  good morning datafruits 06-28-2017","position":13,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-ovenrake-06-28-2016.mp3?1498734297","labels":[1,5]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-salinger-guestforkandknife-06-28-2017.mp3","podcast_published_date":"2017-06-29T10:41:43.823Z","id":1945,"track_id":2071,"playlist_id":3,"title":"salinger - guest fork and knife - 06-28-2017","display_name":"salinger - guest fork and knife - 06-28-2017","position":14,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-salinger-guestforkandknife-06-28-2017.mp3?1498733083","labels":[3,4]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-gearshfft-and-options-06-28-2017.mp3","podcast_published_date":"2017-06-28T07:44:06.270Z","id":1890,"track_id":2013,"playlist_id":3,"title":"softserve presents \u0026 Options - 06-28-2017","display_name":"softserve presents \u0026 Options - 06-28-2017","position":15,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-gearshfft-and-options-06-28-2017.mp3?1498631166","labels":[16]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafriuts-fengirs-key-with-wankers-united-06-24-2017.mp3","podcast_published_date":"2017-06-25T23:57:00.594Z","id":1889,"track_id":2012,"playlist_id":3,"title":"fengir's key - with wanker's united live set - 06-24-2017","display_name":"fengir's key - with wanker's united live set - 06-24-2017","position":16,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafriuts-fengirs-key-with-wankers-united-06-24-2017.mp3?1498537732","labels":[11]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-salinger-06-14-2017.mp3","podcast_published_date":"2017-06-15T08:42:00.580Z","id":1864,"track_id":1989,"playlist_id":3,"title":"salinger - 06-14-2017","display_name":"salinger - 06-14-2017","position":17,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-salinger-06-14-2017.mp3?1498537796","labels":[3,4]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-ovenrake-06-14-2017.mp3","podcast_published_date":"2017-06-15T08:42:00.050Z","id":1863,"track_id":1990,"playlist_id":3,"title":"ovenrake -good morning datafruits -  06-14-2017","display_name":"ovenrake -good morning datafruits -  06-14-2017","position":18,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-ovenrake-06-14-2017.mp3?1498537795","labels":[1,5,10]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-softservefeat.J.DragonJ.DragonMix-05-29-2017.mp3","podcast_published_date":"2017-06-02T05:55:16.632Z","id":1840,"track_id":1950,"playlist_id":3,"title":"gearshfft - softserve feat J.Dragon guest mix - 05-29-2017","display_name":"gearshfft - softserve feat J.Dragon guest mix - 05-29-2017","position":19,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-softservefeat.J.DragonJ.DragonMix-05-29-2017.mp3?1496383027","labels":[1,2,12,13]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-fengir-05-27-2017.mp3","podcast_published_date":"2017-05-29T07:40:20.015Z","id":1834,"track_id":1946,"playlist_id":3,"title":"Fengir's Key - 05-27-2017","display_name":"Fengir's Key - 05-27-2017","position":20,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-fengir-05-27-2017.mp3?1496043870","labels":[11]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-firedrill-guestmix-aspara-05202017.mp3","podcast_published_date":"2017-05-22T08:01:47.892Z","id":1810,"track_id":1920,"playlist_id":3,"title":"firedrill's essential fruits show - guest mix aspara - 05202017","display_name":"firedrill's essential fruits show - guest mix aspara - 05202017","position":21,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-firedrill-guestmix-aspara-05202017.mp3?1495949404","labels":[1,2]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-hpcdude-mmainframe-05-20-2017.mp3","podcast_published_date":"2017-05-22T06:53:14.748Z","id":1809,"track_id":1919,"playlist_id":3,"title":"hpcdude - mmainframe - 05-20-2017","display_name":"hpcdude - mmainframe - 05-20-2017","position":22,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-hpcdude-mmainframe-05-20-2017.mp3?1495632709","labels":[2]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-salinger-05202017.mp3","podcast_published_date":"2017-05-22T06:48:55.050Z","id":1808,"track_id":1918,"playlist_id":3,"title":"salinger - 05202017","display_name":"salinger - 05202017","position":23,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-salinger-05202017.mp3?1496043965","labels":[3,4]},{"audio_file_name":"https://streampusher.s3.amazonaws.com/datafruits/datafruits-ovenrake-05172017.mp3","podcast_published_date":"2017-05-18T00:25:37.821Z","id":1805,"track_id":1917,"playlist_id":3,"title":"ovenrake - good morning datafruits - 05172017","display_name":"ovenrake - good morning datafruits - 05172017","position":24,"updated_at":"2018-03-11T01:37:39.744Z","cdn_url":"https://dongles-dev.streampusher-relay.club/https://streampusher.s3.amazonaws.com/datafruits/datafruits-ovenrake-05172017.mp3?1496043956","labels":[5]}],
"meta":{"page":"1","total_pages":14}}

I can see in the inspector all my models are loading OK. I’m getting this error. I could show you my templates and components, but I think I’m not even hitting that code yet.

Uncaught TypeError: Cannot set property 'length' of undefined
    at Class.objectAt (array_proxy.js:131)
    at objectAt (ember-metal.js:1436)
    at Class._emberMetal.Mixin.create._Mixin$create.slice (array.js:230)
    at Class.objsForPage (divide-into-pages.js:11)
    at Class.<anonymous> (paged-array.js:19)
    at ComputedProperty.get (ember-metal.js:2515)
    at _get (ember-metal.js:1356)
    at Class._addArrangedContentArrayObsever (array_proxy.js:164)
    at Class.init (array_proxy.js:102)
    at Class.CoreObject (core_object.js:145)
objectAt @ array_proxy.js:131
objectAt @ ember-metal.js:1436
_emberMetal.Mixin.create._Mixin$create.slice @ array.js:230
objsForPage @ divide-into-pages.js:11
(anonymous) @ paged-array.js:19
get @ ember-metal.js:2515
_get @ ember-metal.js:1356
_addArrangedContentArrayObsever @ array_proxy.js:164
init @ array_proxy.js:102
CoreObject @ core_object.js:145
EmberObject @ object.js:28
ArrayProxy @ array_proxy.js:79
Class @ core_object.js:207
Class @ core_object.js:207
create @ core_object.js:220
(anonymous) @ paged-array.js:54
get @ ember-metal.js:2515
_get @ ember-metal.js:1356
compute @ ember-glimmer.js:346
value @ ember-glimmer.js:223
iterate @ ember-glimmer.js:2634
isEmpty @ reference.js:465
value @ runtime.js:1703
initialize @ reference.js:390
peek @ reference.js:364
(anonymous) @ runtime.js:678
evaluate @ runtime.js:46
evaluateSyscall @ runtime.js:2896
evaluateInner @ runtime.js:2868
evaluateOuter @ runtime.js:2860
next @ runtime.js:4788
execute @ runtime.js:4773
handleException @ runtime.js:3753
handleException @ runtime.js:3923
_throw @ runtime.js:3658
evaluate @ runtime.js:730
execute @ runtime.js:3645
rerender @ runtime.js:3950
_this30.render @ ember-glimmer.js:4075
runInTransaction @ ember-metal.js:406
_renderRoots @ ember-glimmer.js:4340
_renderRootsTransaction @ ember-glimmer.js:4372
_revalidate @ ember-glimmer.js:4412
invoke @ backburner.js:247
flush @ backburner.js:167
flush @ backburner.js:326
_end @ backburner.js:748
end @ backburner.js:513
_run @ backburner.js:793
_join @ backburner.js:769
join @ backburner.js:567
join @ index.js:164
hash.success @ rest.js:876
fire @ jquery.js:3268
fireWith @ jquery.js:3398
done @ jquery.js:9305
(anonymous) @ jquery.js:9548
load (async)
send @ jquery.js:9567
ajax @ jquery.js:9206
_ajaxRequest @ rest.js:893
_ajax @ rest.js:913
(anonymous) @ rest.js:883
initializePromise @ rsvp.js:397
Promise @ rsvp.js:877
ajax @ rest.js:873
findAll @ rest.js:459
Ember.RSVP.Promise.resolve.then @ -private.js:9290
tryCatcher @ rsvp.js:200
invokeCallback @ rsvp.js:372
(anonymous) @ rsvp.js:436
(anonymous) @ rsvp.js:14
invoke @ backburner.js:247
flush @ backburner.js:167
flush @ backburner.js:326
_end @ backburner.js:748
end @ backburner.js:513
_run @ backburner.js:793
_join @ backburner.js:769
join @ backburner.js:567
join @ index.js:164
(anonymous) @ index.js:265
mightThrow @ jquery.js:3534
process @ jquery.js:3602
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
ready @ jquery.js:3878
completed @ jquery.js:3888

Please let me know if I can provide any more info, or if you think I should ask somewhere else…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
brandontksmithcommented, Oct 4, 2018

I too am experiencing this issue.

3reactions
synaptikocommented, Jan 4, 2019

I have just found this problem after upgrade to 3.5 as well. I’ve been debugging it for some time and I think the main issue is that init method of PagedRemoteArray is not calling this._super(...arguments). Once I added it it’s working again.

I may create a PR but this project doesn’t seem to be very active recently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property Length of Undefined in JavaScript
The JavaScript TypeError: Cannot read property 'length' of undefined occurs when the length property is read on an undefined variable.
Read more >
Typeerror: Cannot Read Property 'length' of Undefined
A typeerror length of undefined can indicate that the actual type of an operand is different from the expected type. This error can...
Read more >
Uncaught TypeError: Cannot read property 'length' of undefined
The solution is check for null or undefined (to see whether the object exists) and only then iterate. Share.
Read more >
Cannot read properties of undefined (reading 'length') - TrackJS
This message indicates that our code expects to have an object with a length property, but that object was not present. length is...
Read more >
[SOLVED] Cannot Read Property 'length' of Undefined in JS
4 Quick Fixes for the “Cannot Read Property 'length' of Undefined” Error in JavaScript · 1. Use an if Statement · 2. Use...
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