| Reference | Downloads | Github

ReferenceError: frameDur is not defined. Problem converting from pyschopy to JS?

URL of experiment:

Description of the problem: Problem running task, ReferenceError: frameDur is not defined.

The problem I am having is with a task that I have built in PsychoPy builder (which runs smoothly) and now I want to put online. I have converted it to JavaScript and uploaded to PsychoPy but am now getting the error message:

ReferenceError: frameDur is not defined.

When I try and debug this it is telling me that frameDur is not defined in core2020.1.js.1438 (see picture below for Java Error in Chrome)

If I add var frameDur; to the top of my script this error message disappears but new error messages appear telling me that there is a problem with the core.Clock?

I am not really sure what to do next, to fix this error? Any help would be much appreciated.

@cathgrainger, this usually means that there has been an issue compiling your HTML/JavaScript in PsychoPy. There should have been an error output in the dialog box when you synced your task, which will give you an idea of what went wrong.

1 Like

Not defined usually means it needs to be in a Begin Experiment block.

Check out my crib sheet for how to translate core clock. I’m on my phone at the moment

Hey @wakecarter, this might be useful to add to your sheet, that frameDur is a PsychoJS variable used for calculating frame durations. This error tends to occur when the JS has not compiled correctly, and so PsychoPy fails to declare the builtin variables in the JS code. The actual error is usually visible from the Psychopy dialog.

1 Like

@wakecarter and @dvbridges thank you for your help. It did seem to be an issue compiling the HTML/Javascript from PyschoPy as when I did this again I noticed the error output flagged several errors.

Many thanks,

Hi there,
I have the frameDur not defined error when running the study online on Pavlovia. I did not encounter any error when compiling from psychopy ( 2020.1.2). I have one code component in one of my routine about mouse click. Do you think this could be the source of the issue please. Any help is appreciated.
When I manually added var frameDur; in the .js file in git the error went away but other errors followed. Is there a way to fix this without manually putting all the var ?

As per Jon’s post here:

it’s probably worth trying to work out why frameDur wasn’t initialised. Do you have, for example, any blank onset values? The new errors you got when you manually fixed frameDur might give you a clue.