# \*\*ReferenceError: Can't find variable: currentLoop\*\*

**URL:** <https://discourse.psychopy.org/t/referenceerror-cant-find-variable-currentloop/41155>\
**Category:** Online experiments\
**Created:** [August 23, 2024, 4:49pm UTC](https://discourse.psychopy.org/t/referenceerror-cant-find-variable-currentloop/41155 "2024-08-23T16:49:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Boquoi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/max_boquoi/32/42366_2.png) [@Max\_Boquoi](https://discourse.psychopy.org/u/Max_Boquoi)\
**Post date:** [August 23, 2024, 4:49pm UTC](https://discourse.psychopy.org/t/referenceerror-cant-find-variable-currentloop/41155/1 "2024-08-23T16:49:16Z")

</div>

I was contacted by a person trying to do my experiment that it didn’t work. After solving the “experiment stuck on initialising” and “couldn’t download file” issues, I now run into this error message:

URL of experiment: [Chromasthesia [PsychoPy]](https://run.pavlovia.org/mboquoi/chromasthesia)

Description of the problem:

> Unfortunately we encountered the following error:
> 
> - **ReferenceError: Can’t find variable: currentLoop**

The Safari Webdeveloper refers me to a “Scheduler.js”, with the faulty lines being within:

> // run the next scheduled tasks until a scene render is requested:  
> const state = await self.\_runNextTasks();  
> if (state === Scheduler.Event.QUIT)

It highlights the middle one,

> ```
> const state = await self._runNextTasks();
> 
> ```

I do not know what to do. Please help,  
thanks in advance,

Max

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [August 24, 2024, 6:59am UTC](https://discourse.psychopy.org/t/referenceerror-cant-find-variable-currentloop/41155/2 "2024-08-24T06:59:23Z")

</div>

Do you have any loops? This post may help.

> [@No loop but this error "ReferenceError: currentLoop is not defined"](https://discourse.psychopy.org/t/no-loop-but-this-error-referenceerror-currentloop-is-not-defined/27684/7):
>
> Try adding a loop around your entire experiment with 1 repetition and no spreadsheet. I think that online experiments may have difficulty saving data not in loops.

---

<div class="post-metadata">

**Author:** ![Max\_Boquoi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/max_boquoi/32/42366_2.png) [@Max\_Boquoi](https://discourse.psychopy.org/u/Max_Boquoi)\
**Post date:** [August 24, 2024, 12:58pm UTC](https://discourse.psychopy.org/t/referenceerror-cant-find-variable-currentloop/41155/3 "2024-08-24T12:58:04Z")

</div>

Hi,  
I do have two loops in my experiment and I now added a third with 1 rep and no spreadsheet, like you suggested. That however did not solve the problem, nor the error.  
Interestingly I found out that the experiment.js that they use differs in my browser from the one I have (and the one in gitlab). Additionally I found this error code:

> ReferenceError: Can’t find variable: currentLoop
> 
> async function updateInfo() {  
> currentLoop = psychoJS.experiment; // right now there are no loops  
> expInfo[‘date’] = util.MonotonicClock.getDateStr(); // add a simple timestamp  
> expInfo[‘expName’] = expName;  
> expInfo[‘psychopyVersion’] = ‘2024.1.5’;  
> expInfo[‘OS’] = window.navigator.platform;

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [August 24, 2024, 5:42pm UTC](https://discourse.psychopy.org/t/referenceerror-cant-find-variable-currentloop/41155/4 "2024-08-24T17:42:35Z")

</div>

Don’t worry about an overarching loop if you already have loops

Have you ticked “is trials” in your liops?
