# Circumstances in which loadAsync doesn't work

**URL:** <https://forum.babylonjs.com/t/circumstances-in-which-loadasync-doesnt-work/6148>\
**Category:** Bugs\
**Created:** [October 7, 2019, 1:15pm UTC](https://forum.babylonjs.com/t/circumstances-in-which-loadasync-doesnt-work/6148 "2019-10-07T13:15:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pietrko](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pietrko](https://forum.babylonjs.com/u/pietrko)\
**Post date:** [October 7, 2019, 1:15pm UTC](https://forum.babylonjs.com/t/circumstances-in-which-loadasync-doesnt-work/6148/1 "2019-10-07T13:15:47Z")

</div>

Hey,

what are circumstances in which

```auto
 assetsManager.loadAsync()
```

may not work?

I am really puzzled since the promise i get when calling this method has state “Pending” forever and none of the “then” handlers are triggered.  
The assetsManager.load() works like a charm though.

Here’s the code:

```auto

    187 addTask(name, meshSubdir) {    
    188 let self = this;                                                               
    189 let load_path = DATA_FILES + "/" + meshSubdir + "/";                            
    190 let meshTask = this.assetsManager.addMeshTask("task_" + name, "", load_path, name + '.babylon');
    191 this.tasks[name] = meshTask;                                                             
    192                                                    
    193                                                     
    194 meshTask.onSuccess = function (task) {                                                  
    195 const scale = MESH_SCALING[meshSubdir];                                              
    196 let loadedMesh = meshTask.loadedMeshes[0]    
    197 loadedMesh.scaling = new BABYLON.Vector3(scale, scale, scale)
    198 loadedMesh.isVisible = false;                                       
    199 self.meshes[name] = loadedMesh;
    200 self._recomputeScene();                                  
    201 console.log('DEBUG: model:' + name + ' loaded successfully');
    202 }                         
    203 meshTask.onError = function (task, message, exception) {         
    204 console.log('EXCEPTION: Mesh with name ' + name + ' not loaded:', message, exception)      
    205 }                            
    206                                                                      
    207 console.log('DEBUG: Added ' + meshTask.name + ' to task asset manager' );             
    208 let promise = this.assetsManager.loadAsync();                                          
    209 promise.then(function (tasks) { console.log(tasks)});                                         
    210                                                                                                                                                         
    211 }
```

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 7, 2019, 2:00pm UTC](https://forum.babylonjs.com/t/circumstances-in-which-loadasync-doesnt-work/6148/2 "2019-10-07T14:00:47Z")

</div>

It should work the same. Can you repro in the Playground?

---

<div class="post-metadata">

**Author:** ![pietrko](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pietrko](https://forum.babylonjs.com/u/pietrko)\
**Post date:** [October 7, 2019, 2:34pm UTC](https://forum.babylonjs.com/t/circumstances-in-which-loadasync-doesnt-work/6148/3 "2019-10-07T14:34:38Z")

</div>

Ok found the problem, here is the code from plagroudn for loadAsync:

```auto
            e.prototype.loadAsync = function() {
                var e = this;
                return new Promise(function(t, i) {
                    e._isLoading ? t() : (e.onTasksDoneObservable.addOnce(function(e) {
                        e && e.length ? i(e) : t()
                    }),
                    e.load())
                }
              
```

Here is the code in my local version (which is downloaded from cdn.babylon)

```auto
loadAsync = function () {
        let e = this;                                    
        return new Promise(function(t, i) {                                 
            e.onTasksDoneObservable.addOnce(function(e) {      
                e && e.length ? i(e) : t()                     
         })                                                                         
 })
```

I’ve checked second time indeed the code looks like it when downloaded from [[https://cdn.babylonjs.com/babylon.max.js](https://cdn.babylonjs.com/babylon.max.js)]([http://babylon](http://babylon) cdn)

Should it be the case? Which code is right? Surly the code from latest version (from CDN) doesn’t give expected results.  
I would say it’s a bug.  
Playground code (older) works.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 7, 2019, 9:01pm UTC](https://forum.babylonjs.com/t/circumstances-in-which-loadasync-doesnt-work/6148/4 "2019-10-07T21:01:43Z")

</div>

Do you mind sharing the repro link?
