No loop but this error "ReferenceError: currentLoop is not defined"

URL of experiment: fscratch [PsychoPy]

Description of the problem:

Hi everyone. I am trying to make a simple experiment here that just plays some audio with text on the screen. Then after the audio finishes, it goes to a “press space for the next segment” screen.

I get the error listed in the title even though currently there is almost nothing in the file. I tried it with one that has 10 frames and got that error, decided to start from scratch because I couldn’t figure out why there was an error. I added an instructions frame and the first audio clip frame and the error was still there.

I have no idea how to fix this… Please let me know if you know the solution, it is probably something basic because I am a novice.

Thanks in advance!

I appreciate all of you.

Link to the testing files on G Drive: LINK

Did you know that .ogg sound files don’t work online? You need to either use ogg locally and mp3 online or use wav, which is second best for both locations.

Hi Wakecarter,

I did not know that. However, I still received that error removing the second frame which contained the ogg. Does just having the ogg in the synced folder cause a problem, even if it is not in the psychopy file?

Having an .ogg file in the folder is not a problem.

The error is in the line

 if (currentLoop instanceof MultiStairHandler) {
      currentLoop.addResponse(key_resp.corr, level);

I couldn’t see a staircase in your Builder file.

However, I also couldn’t work out why you have a loop called trials with nReps = 1 and no spreadsheet.

The issue might be that you have this one loop with “is trials” disabled, suggesting that you don’t want the data to be saved for each iteration, and yet there is no preceding loop. Try ticking is trials (or removing the loop).

I am having the same error message when piloting a study that has no loops and just text and images. using the developer tools I can also see that I’m getting an error on the same line:

if (currentLoop instanceof MultiStairHandler) {
currentLoop.addResponse(SAM_1_instructions_key.corr, level)

were you able to figure it out?

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.

1 Like

I ended up just deleting the multi stair handler in JS and that worked- if it ends up messing something else up, I’ll try adding a loop

This solution worked for me

Hello! I had exactly the same problem, added a loop around the entire experiment but that didn’t work… Still getting “Reference Error: currentLoop is not defined”.

Did you refresh your cache to ensure you were running the latest version of your code?

Just did that, now the error changed

  • TypeError: Set is not a constructor

Do you have a column called Set in your spreadsheet?

Thank you for the help, taking the Set column solved the problem.

Hey everyone, I am having the same issue and I have tried the steps here and no luck. Any other ideas? The error is in this code:

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’] = ‘2022.2.5’;
expInfo[‘OS’] = window.navigator.platform;


What version of PsychoPy are you using?

Have you tried putting a loop around your whole flow with 1 rep and no spreadsheet (as suggested above).?

Hey, thanks for the reply.

I’m using v2022.2.5 and I’ve tried putting a loop around my whole flow but it didn’t work.

Try an incognito tab to check you are looking at the latest version.

Check the experiment page to confirm it is running in 2022.2.5.

Both checked. I’ve tried an incognito tab and no luck. Also experiment page says it’s running 2022.2.5

Have you checked the console to see what line is giving the error? Do you have any custom code referring to cutrentLoop?