From 44ffbff63e4cae33ab519b23d51394645d7ccab1 Mon Sep 17 00:00:00 2001 From: Will Bagby Date: Mon, 27 Mar 2017 13:00:38 -0700 Subject: [PATCH] Ember.warn when ManyArray.objectAt() is underfined --- addon/-private/system/many-array.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addon/-private/system/many-array.js b/addon/-private/system/many-array.js index 6aa7f000fba..78433bd4e31 100644 --- a/addon/-private/system/many-array.js +++ b/addon/-private/system/many-array.js @@ -2,7 +2,7 @@ @module ember-data */ import Ember from 'ember'; -import { assert } from "ember-data/-private/debug"; +import { assert, warn } from "ember-data/-private/debug"; import { PromiseArray } from "./promise-proxies"; import { _objectIsAlive } from "./store/common"; import diffArray from './diff-array'; @@ -136,7 +136,12 @@ export default Ember.Object.extend(Ember.MutableArray, Ember.Evented, { objectAt(index) { let object = this.currentState[index]; //Ember observers such as 'firstObject', 'lastObject' might do out of bounds accesses - if (object === undefined) { return; } + if (object === undefined) { + warn(`ManyArray#objectAt(index) return undefined for index '${index}'. See https://github.com/emberjs/data/issues/4758`, false, { + id: 'ds.many-array.object-at-undefined' + }); + return; + } return object.getRecord(); },