Cannot use outerLoop.finish when run online

URL of experiment:

Description of the problem:
I am using v2020.1.2 on OSX
The outerLoop of a nested 2 loop experiment is not responding to the outerLoop.finish command when run online, however the innerLoop operates correctly. The code runs correctly using builder.

I created a cutdown experiment to demonstrate the issue.
The intention is that a ‘return’ , ‘c’ , ‘f’ on the keyboard component will force end the doRoutine.

if its a ‘return’ it simply steps to the next row of the inner loop (and proceeds to outer loop if inner loop completed)
if its a ‘c’ it will terminate the inner loop.
if its an ‘f’ it will also terminate the outer loop hence finish the program.

What happens when run online is that the ‘f’ key just terminates the inner loop and ignores the outerLoop.finish

In order to get round the problem I have used several versions of the code back to v3.1.5 but non worked correctly and I tied myself up in knots.

I have read that use can be made of trials.finish regardless of the actual loop name to finish a loop ie: "all loops are called “trials”. and “for nested loops the inner loop is referenced. It may not be possible to reference the outer loop ( refer to discourse 11190)”.

My question is : am I correct that nested looping indeed dosn’t directly convert from Python to JS and if so would it be easier to implement nested loops directly coding into JS or creating an alternative workround method directly addressing rows in just a single loop which can be terminated by the loop.finish method.

Any confirmations suggestions would be appreciated, as said I’m very confused on how to proceed.

Thanks

@barrieu, the method for breaking loops is different online, you need to use trials.finished = true. All loops are broken this way, and so you will have to control the breaking of each loop using a code component directly within that loop, since you cannot break the loop by referencing the loop by name.

@dvbridges, thanks David, I changed the innerLoop.finished and outerLoop.finished statements to trials.finished = true; and still the outerLoop does not break, just does another cycle of the innerLoop.

Screenshot showing code block End Routine and resulting JS

function doRoutineRoutineEnd() {
  //------Ending Routine 'doRoutine'-------
  for (const thisComponent of doRoutineComponents) {
    if (typeof thisComponent.setAutoDraw === 'function') {
      thisComponent.setAutoDraw(false);
    }
  }
  psychoJS.experiment.addData('key_resp.keys', key_resp.keys);
  if (typeof key_resp.keys !== undefined) {  // we had a response
      psychoJS.experiment.addData('key_resp.rt', key_resp.rt);
      routineTimer.reset();
      }
  
  key_resp.stop();
  if ((key_resp.keys === "c")) {
      trials.finished = true;
  } else {
      if ((key_resp.keys === "f")) {
          trials.finished = true;
          trials.finished = true;
      }
  }
  
  // the Routine "doRoutine" was not non-slip safe, so reset the non-slip timer
  routineTimer.reset();
  
  return Scheduler.Event.NEXT;
}

Hi did you ever find a solution to this?