Unspecified Error Only After Extra Trials

URL of experiment: Sign in · GitLab

Description of the problem:
The task works locally, even in the js debug mode. It also runs correctly on Pavlovia, and the output looks as I want it to in all my pilot runs.

However, I added a third block in my last update, and after 13 trials, the “unspecified JavaScript error” (see below) appears. The trials continue to run, and you can still respond. The output is still correct. But it seems the box will continue to appear on each trial, even after closing it. There is no error in the local debug mode.

It seems to be specific to the number of trials, as I’ve tried to have a third block with only 12 trials, and this runs on Pavlovia with no error messages appearing. At exactly 13 trials, the task completes successfully, and then the error message appears (attached image). Any more than that, and the error repeats almost every trial.

I have next to 0 experience with JavaScript, and I’m still learning my way around getting tasks running online, so any help would be greatly appreciated!

Note: This experiment does have a code component, as the tones (there are 3) are supposed to be counted. The participant listens to each, and is supposed to hit a button on the 4th presentation of each tone. If they’re wrong, the count of that tone resets to 0. My block files all have a column labeled “idx”, which is the variable here. It looks like this ("#???" are placeholders for optional extra info):

In “Begin Experiment”:

counts = [0, 0, 0]

In “End Routine”:

if key_resp.keys == 'space':
 if counts[idx] % 4 == 0:
  key_resp.corr = 1; #correct response
  # If the count is not %4, it's wrong
 else:
  key_resp.corr = 0
  counts[idx] = 0 # resets counter
else:
 if counts[idx] % 4 == 0:
  key_resp.corr = 0
  # ???
 else:
  key_resp.corr = 1
  # ???
trials.addData('key_resp.corr', key_resp.corr)
trials.addData('key_resp.keys', key_resp.keys)

Thank you!