TypeError: core.CountdownTimer is not a constructor

URL of experiment: https://run.pavlovia.org/wdstahlm/version-2

Description of the problem: I’m using a countdown timer to control the duration of a loop, and when I try piloting the experiment on Pavlovia, I am getting the following error: core.CountdownTimer is not a constructor. When I made the experiment, I used a code component to write this code and set it to Auto->JS. Anyone have any suggestions?

Please have a look at my code snippets for working with clocks.


Thank you for the reply. I’m still a little confused, I used this countdown timer to end my loop, and I don’t see on this sheet a translation for the countdown timer code. I’ve included the auto-translated JS code below.

Begin Experiment:

countdownStarted = false;

Begin Routine:

if ((! countdownStarted)) {
    countdownClock = new core.CountdownTimer(600);
    countdownStarted = true;

Each frame:

timeRemaining = countdownClock.getTime();
if ((timeRemaining <= 0.0)) {
    continueRoutine = false;
    trials.finished = true;
    countdownStarted = false;
} else {
    minutes = Number.parseInt((timeRemaining / 60.0));
    seconds = Number.parseInt((timeRemaining - (minutes * 60.0)));
    timeText = ((minutes.toString() + ":") + seconds.toString());

Sorry I didn’t realise countdowntimer was its own thing. I’d recommend that you use define a clock which will work online

So, I can use the core.clocks function and the translations you provided instead of the countdown timer, and simply write some code such that when the clock reaches a certain time, the trials loop is finished? I had a lot of issues with trying to create a temporal loop other ways in the past, so I’m hoping this would work.

Correct, though quite a bit of my code snippet is about displaying the clock, which I’m not sure you need.

I do still want to display the time remaining, that’s why I was using the countdown timer, so I will have to find a way to display time remaining while still using the clock instead.

I was able to solve the construct error, however now I am getting an error that minutes are not defined. The python equivalent of the code ran fine from the builder. I have the following JS code in the each frame tab:

timeRunning = timerClock.getTime();
if ((timeRunning >= 600)) {
    continueRoutine = false;
    trials.finished = true;
    timerStarted = false;
} else {
    minutes = Number.parseInt(((600 - timeRunning) / 60.0));
    seconds = Number.parseInt(((600 - timeRunning) - (minutes * 60.0)));
    timeText = ((minutes.toString() + ":") + seconds.toString());

Do you have any advice? I apologize for so many questions, I don’t know JS at all!

Put minutes = 0 and seconds =0 in Begin Experiment

Worked! Thank you

I am running into this error myself now, but neither using util.CountdownTimer(); from PsychoJS or switching to new util.Clock(); alleviates the error, even though there appears to be no sign of the cited “core.CountdownTimer” in the JS code any more (pavlovia experiment here)…

Any help will be greatly appreciated! :melting_face: