# ReferenceError: setTimeout is not defined in ember-template-compiler-3.1.1.js

**URL:** <https://discuss.emberjs.com/t/referenceerror-settimeout-is-not-defined-in-ember-template-compiler-3-1-1-js/14897>\
**Category:** Ember CLI\
**Created:** [June 6, 2018, 8:14am UTC](https://discuss.emberjs.com/t/referenceerror-settimeout-is-not-defined-in-ember-template-compiler-3-1-1-js/14897 "2018-06-06T08:14:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vothaison](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/vothaison/32/17013_2.png) [@vothaison](https://discuss.emberjs.com/u/vothaison)\
**Post date:** [June 6, 2018, 8:14am UTC](https://discuss.emberjs.com/t/referenceerror-settimeout-is-not-defined-in-ember-template-compiler-3-1-1-js/14897/1 "2018-06-06T08:14:30Z")

</div>

Hi,

We are migrating from Ember 2.x to Ember 3.x (3.1.1 for now). We have been using MSIE JavaScript Engine to precompile templates, and it works great with Ember 2.x;

Now There is a problem when we precompile templates with ember-template-compiler-3.1.1.js. It is now using the global setTimeout() function which is not available in JavaScript engines. And so, script engine throws when it tries to execute ember-template-compiler-3.1.1.js file.

`'Script threw an exception: 'setTimeout' is undefined'`

```
ReferenceError: setTimeout is not defined
    at ember-template-compiler-3.1.1-.js:4355:23 -> var SET_TIMEOUT = setTimeout;
    at internalRequire (ember-template-compiler-3.1.1-.js:62:16)
    at internalRequire (ember-template-compiler-3.1.1-.js:58:24)
    at internalRequire (ember-template-compiler-3.1.1-.js:58:24)
    at requireModule (ember-template-compiler-3.1.1-.js:95:14)
    at ember-template-compiler-3.1.1-.js:17908:92
    at ember-template-compiler-3.1.1-.js:17911:2

```

I wonder is that configurable. i.e can we switch setTimeout() implementation to work with JavaScript engines? And, what is the problem with the old implementation of setTimeout()?

Thanks.

---

<div class="post-metadata">

**Author:** ![rwjblue](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rwjblue/32/9411_2.png) [@rwjblue](https://discuss.emberjs.com/u/rwjblue)\
**Post date:** [June 6, 2018, 11:17am UTC](https://discuss.emberjs.com/t/referenceerror-settimeout-is-not-defined-in-ember-template-compiler-3-1-1-js/14897/2 "2018-06-06T11:17:48Z")

</div>

The engine you are using to compile with doesn’t have a `setTimeout`?

---

<div class="post-metadata">

**Author:** ![rwjblue](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rwjblue/32/9411_2.png) [@rwjblue](https://discuss.emberjs.com/u/rwjblue)\
**Post date:** [June 6, 2018, 11:25am UTC](https://discuss.emberjs.com/t/referenceerror-settimeout-is-not-defined-in-ember-template-compiler-3-1-1-js/14897/3 "2018-06-06T11:25:16Z")

</div>

This code is part of `Backburner.js` which is included in `ember-template-compiler.js` to satisfy imports (which would error if not present) but it essentially unused during template compilation.

Newer versions of Ember do not include this code in their `ember-template-compiler.js` (at least 3.3.0-beta.1, but _possibly_ 3.2.0).

---

<div class="post-metadata">

**Author:** ![vothaison](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/vothaison/32/17013_2.png) [@vothaison](https://discuss.emberjs.com/u/vothaison)\
**Post date:** [June 7, 2018, 2:54am UTC](https://discuss.emberjs.com/t/referenceerror-settimeout-is-not-defined-in-ember-template-compiler-3-1-1-js/14897/4 "2018-06-07T02:54:52Z")

</div>

Thanks for the replies, @rwjblue

Yes, the engine we are using to precompile with doesn’t have a setTimeout. It’s MSIE Script Engine. And the other engines I have tested are V8, Chakra, Jurassic, EdgeJS. They all throw that exception. Everyone says setTimeout is not part of ES6 specification, so it is not implemented into script engines. I also have tried PhantomJS but it has a problem with `weakmap`.

So, I guess we will have to skip a few versions and wait for the stable version of Ember 3.2.0.

Thanks, And also big thanks to the awesome Ember Collection component. 😃
