JS Hex error and undefined (reading 'toString')

URL of experiment:

Description of the problem:

Dear all,

I have just created a trial for a study using essentially builder, no coding (PsychoPy v2023.1.2). The trial is very simple, it is composed of a slider, some text, and some pictures - one that is constant on the screen and another that changes according to the user’s choices in the slider (see picture).

The problem is that the experiment runs in Psychopy but not when I try to run it through pavlovia (or local browser) I get error messages. The error messages change whether I run it in Mozilla or in Chrome.


Chrome (cannot attack another image, so I will just copy and paste the text):

Unfortunately we encountered the following error: TypeError: Cannot read properties of undefined (reading ‘toString’). Try to run the experiment again. If the error persists, contact the experiment designer.

Anyone has any idea what is going on?

Thank you for your help!

  1. Can you please share your .psyexp file?
  2. Can you try this again, and when you get this error, open your browser’s developer console (under “view” → “developer” in Chrome or cmd-alt-J on Mac, shift-ctrl-J on Windows, same in Firefox). This should give you a more complete error message with the line number and some context.


Thanks a lot for your help!

I am sharing the whole folder with the .psyexp file so everything the stimulus needs is there:

IrInfo.zip (5.7 MB)

I have checked the developer console and it did give me more information, but I still don’t know what to do. I am also sharing the console information here.
consoleinfo.zip (3.4 KB)

Thanks again!

I found the source of the error. It’s in your code element, in the “Begin experiment” section:

psychoJS.window.color = 'black';
var slider_choices = [];
var timestamps = [];

The issue is in trying to set the window color and flip the window through code. For whatever reason, PsychoJS really doesn’t like that. If you comment out the ‘Flip’ you get the error from Chrome, if you comment out both of the window modifications it now gives me an error because it couldn’t find the image specified in the code, but otherwise it works. You should be able to set the window background color in the experiment settings instead, and I recommend adding the images to the “additional resources” setting under “online” as well.

1 Like

Thank you very much! Indeed, that was the problem and you’re right that now I get an error for not finding the images specified in the code (although this is not a problem in the python script).

I am trying to figure this problem out but if I can’t I will create another topic :smile: .

Thank you again for your help, Jonathan!