Skip to content

Commit

Permalink
[BUGFIX lts] Enable maximum rerendering limit to be customized.
Browse files Browse the repository at this point in the history
As of Ember 3.4 the autorun assertion is removed, and usage of native
promises has increase the likely hood that this rerender limit of 10
will be hit in "normal" scenarios.

Co-authored-by: Kris Selden <[email protected]>
  • Loading branch information
rwjblue and krisselden committed Mar 4, 2019
1 parent 1e1f22a commit f0322f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/@ember/-internals/environment/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ export const ENV = {
*/
_JQUERY_INTEGRATION: true,

/**
Controls the maximum number of scheduled rerenders without "settling". In general,
applications should not need to modify this environment variable, but please
open an issue so that we can determine if a better default value is needed.
@property _RERENDER_LOOP_LIMIT
@for EmberENV
@type number
@default 1000
@private
*/
_RERENDER_LOOP_LIMIT: 1000,

EMBER_LOAD_HOOKS: {} as {
[hook: string]: Function[];
},
Expand Down
3 changes: 2 additions & 1 deletion packages/@ember/-internals/glimmer/lib/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ENV } from '@ember/-internals/environment';
import { runInTransaction, setHasViews } from '@ember/-internals/metal';
import {
fallbackViewRegistry,
Expand Down Expand Up @@ -229,7 +230,7 @@ let loops = 0;
function loopEnd() {
for (let i = 0; i < renderers.length; i++) {
if (!renderers[i]._isValid()) {
if (loops > 10) {
if (loops > ENV._RERENDER_LOOP_LIMIT) {
loops = 0;
// TODO: do something better
renderers[i].destroy();
Expand Down
1 change: 1 addition & 0 deletions tests/docs/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'[]',
'_APPLICATION_TEMPLATE_WRAPPER',
'_JQUERY_INTEGRATION',
'_RERENDER_LOOP_LIMIT',
'_TEMPLATE_ONLY_GLIMMER_COMPONENTS',
'__container__',
'_activeQPChanged',
Expand Down

0 comments on commit f0322f5

Please sign in to comment.