Issue in jsPsych–Pavlovia integration: jsPsych.plugins.parameterType is undefined

jsPsych version: 6.1.0, Pavlovia version: 2020.4

(sorry about formatting, I was only allowed to include two links)

Hi all,

I’ve set everything up to run my jsPsych experiment with Pavlovia, and the actual experiment displays and runs without issues (code here). However, there seems to be a problem in the communication with the Pavlovia server: I’m currently in piloting mode, and at the end of the experiment, neither is my data being redirected to the Pavlovia server (the data file remains empty), nor is the data file being downloaded by my browser as described in the documentation.

The console shows the following error:

Uncaught TypeError: jsPsych.plugins.parameterType is undefined
    pavlovia /jspsych/jspsych-pavlovia-2020.4.js:82
    <anonymous> /jspsych/jspsych-pavlovia-2020.4.js:593

The line of code that is being referenced (82 in jspsych-pavlovia-2020.4.js; 593 is just the closing curly bracket) is the following: = {
		name: 'pavlovia',
		description: 'communication with',
		parameters: {
			command: {
				type: jsPsych.plugins.parameterType.STRING,
				pretty_name: 'Command',
				default: 'init',
				description: 'The pavlovia command: "init" (default) or "finish"'

If I’m not mistaken, this means that the code in my timeline file (see this file, lines 36–40, 82–83, 174–178, and 180) iniating and terminating communication with pavlovia is not being read because of some variable definition problem.

Now, when I check my jspsych.js file, it is not clear to me that “parameterType” is undefined. There are a bunch of references in there to “plugins.parameterType” (but I obviously didn’t write this code myself, so I can’t be sure what it does).

Someone else posted about this same issue before but ultimately went with running the experiment elsewhere, so this was never solved.

Can anybody tell me what part I need to define in my code? Or might this be an issue arising from conflicting jsPsych, Pavlovia, and perhaps even jQuery versions?

Thank you!

Hi There,

This code looks a little different to the jsPsych experiments I have seen before (please note that I personally am way less familiar with jspsych). But I can’t actually see where the pavlovia plugin is added to the timeline (I can’t see a .push() where it is added as is described in this documentation)


Hi Becca, thanks so much for your reply!

The experiment builds on someone else’s work, so it’s also different from what I myself have seen before (a lot less hardcoding, I think) :smiley:

The pavlovia plugin is added to the timeline in this swist-task.js file, lines 36–40, 82–83, 174–178, and 180:

    /* init connection with */
    var pavlovia_init = {
        type: "pavlovia",
        command: "init"


        var intro_timeline = _.flatten([pavlovia_init, card_catch, test_controls,
                                   advisor_intro, advisor_check, attention_check, likelihood_pre, start_task]);

and then the same thing for pavlovia_finish later on. I did try another version that included the X.push command, but it didn’t seem to make a difference. As far as I understand, all that command does is push the thing in question to the timeline variable, and so what the code above does is do that manually?

In any case, I’ll try some different variations of this later today and report back!

Edit: I ran the same code I had yesterday evening just now, and now the experiment actually displays a blank page right after the start. I’m confused because I didn’t change anything and it worked fine before. The error is this:

Uncaught DOMException: Document.querySelector: '#[object Object]' is not a valid selector jspsych.js:132
    jQuery 2

Edit 2: I changed the pavlovia version to v3.2.5 and jsPsych to 6.0.0 and the error from above (uncaught DOMEexception) is gone now. While the experiment runs smoothly again, the communication issue with pavlovia has also returned (Uncaught TypeError: jsPsych.plugins.parameterType is undefined).

Edit 3: I created an experimental version of the timeline (see this file) where the pavlovia_init and pavlovia_finish are properly added. The remaining issue is still the Uncaught TypeError from above.

Hi There,

From taking a quick look here I think it is still running the original non experimental version (the run link suggests it is using scripts/switch-task.js rather than switch-task_EXPERIMENTAL.js) - is that right?

It also looks like you have several timelines rather than 1 - which timeline is it that you want to store pavlovia data from? based only from understanding the description is it that you want to store data only from the intro timeline?


Hi, yes, I switched back to the original version for testing purposes, because the “experimental” one causes a blank screen after the landing page (since the pavlovia_intro is next on the timeline, which doesn’t load because of the variable definition issue, so it makes sense that would happen).

Although there are multiple timelines at first, they come together later in the switch-task.js file (lines 196 and 197):

    var experiment_timeline = [intro_timeline].concat(card_timeline, final_timeline);
    experiment_timeline = _.flatten(experiment_timeline); // Timeline NEEDS to be flat!

And this single concatenated timeline is the one that is then fed into the final jsPsych.init function (lines 208–246):

            timeline: experiment_timeline,


, based on which it then gathers data from across the entire experiment (as listed in lines 233–237):

                    counterbalancing: exp,

So I think the timeline should be fine (?). For what it’s worth, I couldn’t tell you what the “flattened” part is about, I did not code that myself. In any case, the persistent issue really seems to be that error about the undefined variable in jspsych.js:

Could you possibly make a minimally working demo of the bug with your task? e.g. the instructions page and then end the task or end the task after one trial, so that we can see the data pings back to pavlovia at that point.

I tried to fork my end and remove things from the timeline so I could get through the task faster and see the error at the end - but unfortunately without a better understanding of your code (and with my limited JS knowledge) it will take me a while to suss out! (and it will take a while to debug having to complete the whole experiment!)

I set up a version with just the landing page, the first page of the experiment (basic instructions), and the final survey page here: Adani Abutto / working demo representationalvar · GitLab. It uses the experimental timeline and causes the same blank screen after the first page (i.e., when it’s pavlovia_init turn on the timeline) as noted above. I’m adding the errors displayed below.

Interestingly, for this version, my dashboard shows Software Platform: UNKNOWN / no platform version, although the jspsych.js file and pavlovia.js file are the exact same as in my full project (for which it correctly displays jsPsych 6.1.0).

So I still think it has something to do with conflicting jsPsych / pavlovia versions. I will try a few different combinations of jsPsych 6.0, 6.1, and Pavlovia 3.2.4, 3.2.5 later today.

Error 1) Uncaught TypeError: jsPsych.plugins.parameterType is undefined (the familiar one):

Uncaught TypeError: jsPsych.plugins.parameterType is undefined

Error 2) No plugin loaded for trials of type "pavlovia" (full error in img below)

Error 3) Uncaught TypeError: jsPsych.plugins[trial.type] is undefined (full error in img below)


Just in case you want to run the working demo from start to finish: If you remove timeline0.push(advisor_intro); and timeline1.push(pavlovia_finish); from swist-task.js lines #31 and #48, respectively, there is no blank screen. But this of course cuts communication with pavlovia.

Hi There,

Sorry but is it possible to strip it back even more? There are still a large number of files to navigate and I wonder if all are needed to demonstrate the problem.

For instance I tried removing 2 folders that I didn’t think were used based on the index.html (“ToDo” and “_shared”) but that changed the presentation screen see here)

Sorry to be a pain but it takes quite a bit longer to support when there are more files to figure out!


Of course! I’ve now removed every file that isn’t crucial to the demo as best as I could (stored in the same old Git repo). The files in _shared should not be removed, I think, because they contain jQuery as well as further scripts that check the user’s browser version (I did not write that code myself).

From what I can tell, the core files for fixing the issue are these:
index.html (main folder)
jspsych-pavlovia-2020.4.js (/jspsych/) → controls Pavlovia version
jspsych.js (/jspsych/) → controls jsPsych version
swist-task.js (/scripts/) → controls timeline

I didn’t get to testing different version combinations yesterday, but have it on my list for today and will report back later.

Thank you!

So when I try this, I still struggle to get to the end of the experiment to the point where data should ping back, I see the start page then click the start button then I see:

How do I “complete” the experiment to see when the data should ping back?


Currently, when pavlovia_init and pavlovia_finish are integated in the timeline, it is not possible to reach the end of the experiment. This goes back to the “undefined variable” error that I’m trying to figure out:

In any case, I just updated the working demo to a version where pavlovia is not in the timeline so you can get to the end of the experiment. See also this comment here:

This is what the last slide should look like now:

Am I looking at the wrong file here? I can’t see those lines you mention timeline1.push(pavlovia_finish) and I still get the syntax error when trying to comment one of those out?

Hi Becca,

you were looking at the right file! It’s just that I had removed the timeline lines from the code so that one can get to the end of the experiment. But yes, the syntax error (TypeError) occurs either way, unfortunately.

I’ve gone down a bit of a rabbit hole testing different combinations of jsPsych and Pavlovia (6.1 & 3.2.5, 6.1 & 3.2.2, 6.0 & 3.2.5, and 6.0 & 3.2.2, respectively). The version changes didn’t help much, except that the syntax error was a different one. It changed to the “invalid selector” error from earlier:

I looked up what that means and apparently, it has to do with HTML selectors (id/class) having to start with a letter. I checked my entire HTML file, and none of the ids or classes start with a number or hyphen, so that was a dead end, too.

I’m not really sure what else to try at this point :confused:

Hi There,

Apologies for my delay. The only thing that I can think of is that this particular code looks very different from the jsPsych code that I have previously seen (sorry, I do know less about this package, and JS in general, so I’m less well placed to advise here!). We have a range of jsPsych demos that do work with pavlovia, but all the ones I have seen have been formatted like the demos in the docs


Hi Becca,

I realized that much of the code is indeed written in jsPsych version 5-point-something, and I also think that is the root of the issue because the pavlovia plugin seems not to be compatible with that / relies on a more recent version of jsPsych (as I suspected). In any case, we have decided to host the experiment on a local server instead, which has been working just fine! For future projects, I will definitely keep in mind potential version issues. For this one, it was mostly out of my hands because I was building on a task coded by other people, and rewriting it all in jsPsych 6.+ would have taken me forever.

In any case, thanks so much for taking the time out of your day to try and figure this thing out with me!