New error appearing on old task (Can't read property 'map' of undefined)

I have suddenly found this error appearing on a task that I’ve had on Pavlovia for a while. This is a visual search task where participants have to click with their mouse on targets and then click a button that says “Done” to continue.

On the very first trial (and only the first trial), if any of the stimuli are clicked on before the “Done” button appears (after 3 seconds), I get the TypeError. On every other trial, no error occurs.

This is what my routine looks like:

*There are 40 image stimuli, but I didn’t think it was necessary to include them all

The only relevant code component is the DoneButtonClick which has the following in the Each Frame tab:

if t>=3 and MouseResponse.isPressedIn(DoneRectangle, buttons=[0]):

I’m mostly confused as to why this only occurs on the first trial. I have tried moving the mouse component to the top of the routine and this hasn’t helped.


Just an update, this is still an issue and I haven’t been able to figure anything out :(. It’s not a huge deal (I’ve only had 1 participant tell me it’s an issue), but it’s still something I’d like an answer to/be able to resolve if possible!

Hi Eslifkin,

What is that TypeError exactly? Also, are you running your study offline or online?

Best, Thomas

Hi Thomas,

I have attached a screenshot of the error:

I am running the study on Pavlovia, so the error is occurring online. I am not sure if the error occurs offline, as I have some code components that are only in JS so the experiment doesn’t run offline.

Here is a link to my study: VSPMultipleTarget [PsychoPy] (the experiment is public and is running on a license, so no credit worries here!) You must enter a value for dex2px_x and deg2px_y. Entering 30 for both of these is usually a safe bet (stimuli size are dependent on these).

You could take a look in the browser debugger to see where the error occurs. Here is some explanation on how to do that.

Hi Thomas,

I know where the error is occurring in my code, I’m just not sure why it’s occurring. Here is the pertinent line from my .js file:

            if (obj.contains(MouseResponse)) {
              gotValidClick = true;

The error occurs on the first line above. None of this is code that I created; MouseResponse is the name of my mouse component, so this is all auto-compiled by PsychoPy.

The main reason I’m confused as to why this is an issue is because this routine repeats 176 times throughout the experiment and it is only an issue on time 1. The other 175 trials have no issue.

My only thought: Participants have to click on objects on the display and then click on a DONE button to continue. The DONE button doesn’t appear for 3 seconds on each trial. On the first trial, if you click any targets before 3 seconds (before that DONE button appears), you get this error. If you wait until the button appears, you can click anything without an issue. On every other trial, you can click targets before the DONE button appears with no issue.

Any thoughts?

Thanks for the update. My thought is that the first time you’re trying to use something that isn’t defined yet. It’s a bit like this…

repeat stuff below {
  check something about variable X
  give X a value

First round of the loop it fails, second round onward it won’t. What’s the error message in the browser console?

This is what appears in the console:

When I first created the experiment, this wasn’t an issue. It only became an issue later on (I have no idea what I did that could’ve caused this in the interim).