psychopy.org | Reference | Downloads | Github

Unhandled error/ no new js file being created

URL of experiment: https://gitlab.pavlovia.org/knfernandez/two-decision-pathways-online-v2

The paradigm I seem to have an issue was working in pilot mode here, but then would not update: Pavlovia

Description of the problem: For some reason, there is one paradigm that when I add it to my experiments, at some point I am unable to update the experiment on Pavlovia. It appears that this paradigm somehow stops PsychoPy from generating a new JS file, which would explain why it does not update on Pavlovia. I have tried the usual methods of clearing my cache, checking for any empty text components, syntax errors, etc. I have even tried creating the experiment from scratch multiple times and either I can get the experiment to sync once and then it stops, or it completely fails to create a JS file and therefore cannot be run on Pavlovia. I am using PsychoPy version 2020.2.10 since I’ve been working on this for several months and was worried about compatibility issues if I changed. Currently, I am not receiving any errors but the JS file is still not updating.

At this point, I am really hoping it’s something silly I’ve missed or didn’t realize would be an issue. This is the last paradigm I need to get working so I can collect data.

Could you share your gitlab repo with me? (tpronk) I’ll need to be a developer or maintainer

Yes, done. I need the “two decision pathways online v2” one to work, but I you have access to the one titled “Risky Gambles” in case that is helpful at all.

Is it possible there’s something wrong with my Pavlovia account? I am now working on a completely unrelated experiment, and everything was going fine. But, suddenly, I am having the same problem where the JS files are no longer being updated. PsychoPy claims everything synced successfully, but there is an alert that says “Alert 4210:JavaScript Syntax Error in ‘Begin JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Begin JS Experiment’ tab.
For further info see 4210: Probable syntax error detected in your JavaScript code — PsychoPy v2021.1

I deleted some code that was referring to something I removed then tried to sync. I realized that this did not actually update the JS file, so I added the next routine I need since sometimes it seems a code edit isn’t enough to register a change that needs to be synced. I also cleared my cache. However, this also did not update the JS file.

I don’t think there is an issue with your Pavlovia account.

I just examined the first issue you reported using a developer version of PsychoPy 2021.1.3 (that’s code I pull in from GitHub, not packaged as something you can download from psychopy.org yet). This way I could dive into PsychoPy itself to figure out what’s happening. I noticed an interaction between a bug in PsychoPy and a setting in your experiment; somewhere there was a value “2.0” that confused PsychoPy.

I’ve got a fix for the PsychoPy bug, but getting that fix to you might requires us to jump through a couple of hoops. I’ll ask around to see what is the best route to take. Note that the easiest route would probably take a bit of time to wait for the 2021.1.3 release, and would require you to upgrade. If you happen to know where that “2.0” might be coming from, we might be able to think of a workaround.

OK, that is good to know. Is it possibly a problem with the version of PsychoPy I am using, since there are updates I am missing out on from 2021?

I am using “2.0” intentionally while randomly setting an ITI, and also while adjusting an image. I think I was having issues with the results evaluating correctly when I initially added them, but this may now be resolved from updates where I could switch them out to “2” instead? PsychoPy also seems to have added some “2.0” of its own, but here are the ones I added.

    # ------Prepare to start Routine "gamITI"-------
    continueRoutine = True
    # update component parameters for each repeat
    setGambITI = (Math.random() * 2.0) + 1.0
strTimW = ((2.0 - t)/2.0)*1.8

Can you explain why “2.0” would cause an issue? I have other decimal numbers and want to make sure those won’t also result in issues.

To be honest, I’m not sure why this one went wrong and others did not. I can tell you what’s up, for what it’s worth. The function below checks for parameters whether they refer to directories and does some processing. It only works with strings, but the 2.0 got received as number instead. Converting it from a number to a string before converting solves it.

It can be a challenge to trace this back to its source, though I can say it’s probably not in the code you posted, but somewhere in a component property.

My fix

        def getPaths(filePath):
            """Helper to return absolute and relative paths (or None)

            :param filePath: str to a potential file path (rel or abs)
            :return: dict of 'asb' and 'rel' paths or None
            """
            thisFile = {}
            # NB: Pathlib might be neater here but need to be careful
            # e.g. on mac:
            #    Path('C:/test/test.xlsx').is_absolute() returns False
            #    Path('/folder/file.xlsx').relative_to('/Applications') gives error
            #    but os.path.relpath('/folder/file.xlsx', '/Applications') correctly uses ../
            filePathStr = str(filePath);
            if len(filePathStr) > 2 and (filePathStr[0] == "/" or filePathStr[1] == ":")\
                    and os.path.isfile(filePathStr):
                thisFile['abs'] = filePathStr
                thisFile['rel'] = os.path.relpath(filePathStr, srcRoot)
                return thisFile
            else:
                thisFile['rel'] = filePathStr
                thisFile['abs'] = os.path.normpath(join(srcRoot, filePathStr))
                if os.path.isfile(thisFile['abs']):
                    return thisFile

I am not quite sure what/where to implement this fix, sorry.

Since you mentioned the issue is probably in a component, would that possibly look something like this?

    win=win, name='subPerf2',
    vertices=[[-(0.03, 0.03)[0]/2.0,-(0.03, 0.03)[1]/2.0], [+(0.03, 0.03)[0]/2.0,-(0.03, 0.03)[1]/2.0], [0,(0.03, 0.03)[1]/2.0]],
    ori=0, pos=[0,0],
    lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb',
    fillColor=[1,1,1], fillColorSpace='rgb',
    opacity=1.0, depth=-2.0, interpolate=True)

This is a polygon (triangle) that updates coordinates with participant performance/accuracy.

If this is possibly the problem, would disabling during testing potentially allow the code to sync from PsychoPy?

Yes, if that’s the problem, then your experiment should generate JS (or at least give a different problem) when you disable that component. For an actual fix, it depends mostly on whether you’d be willing to upgrade, and/or wait for the next release, and/or got the ability to install a developer version of PsychoPy. How do you feel about that?

I just tested disabling that component (there was another one similar to it that I disabled as well) and syncing with no change to the JS file updating.

I need the experiments to work, so I am willing to upgrade and/or try the developer version. Would I need to completely rebuild my experiments from scratch in 2021 for them to work? Or is it possible that if I upgrade I can edit components so everything works? I’m not 100% sure what the developer version would entail, but I am willing to try!

I would prefer not waiting too much longer as I need to start data collection ASAP and cannot really afford to wait.

All right, let’s try this out then! You’ll be able to open your experiment in 2021 so no worries there.

I believe everything should be setup in terms of git, now.

I assume I also need to install 2021 PsychoPy, but is there another step or anything I should know first?

This procedure does not involve downloading the installer from psychopy.org, instead we’re installing a version of PsychoPy from my GitHub. Just follow the steps I listed in my previous post.

Sorry, I am new to using Git this way and developer tools. Since everything is downloaded/installed, how exactly do I open my experiment in this new version of PsychoPy? I tried looking through discourse and the related websites, but did not find the answer.

You can launch the builder using the CLI command listed here: Installation — PsychoPy v2021.1
python C:\PATH_TO_CLONED_PSYCHOPY_REPO\psychopy\app\psychopyApp

If everything is indeed correctly set up, this should start up my fork, with which I managed to succesfully generate JS from your experiment

Thank you for all your help. I haven’t quite got the developer version working yet, but I was able to try out at least using 2021 which created a JS file. However, upon running that JS file, I noticed that the task that seems to be causing the error was skipped entirely. I was wondering if I could see the JS file your version created to see if the same thing happened?

I have also tried removing any code for the task that seems to cause the PsychoPy to Pavlovia issue, and stick with basic components like text. However, this also does not resolve the issue when running 2020. For some reason, there is something blocking this particular task being updated in the JS file.

I will try to upload a copy to Pavlovia with only the components and see if this at least allows the placeholder component version of the task to appear, but I am not sure what is causing the issue or how to potentially override it. I am also working on getting the dev version, but on a computer that does not already have multiple versions of python or git used for other software.

I shared my version of the gitlab repo with you. Sad to hear your edits didn’t work out. I generated the JS in my version of your experiment with that fork I made of PsychoPy that includes the bug-fix. We’re planning a new release somewhere in the next 1/2 weeks which will include this fix btw.

Thank you for sharing your version with me. Unfortunately, I tried forking and syncing that version and received the following error while trying to sync it locally from my account:

Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\connectionpool.py”, line 384, in _make_request
six.raise_from(e, None)
File “”, line 2, in raise_from
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\connectionpool.py”, line 380, in _make_request
httplib_response = conn.getresponse()
File “C:\Program Files\PsychoPy3\lib\http\client.py”, line 1331, in getresponse
response.begin()
File “C:\Program Files\PsychoPy3\lib\http\client.py”, line 297, in begin
version, status, reason = self._read_status()
File “C:\Program Files\PsychoPy3\lib\http\client.py”, line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), “iso-8859-1”)
File “C:\Program Files\PsychoPy3\lib\socket.py”, line 586, in readinto
return self._sock.recv_into(b)
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\contrib\pyopenssl.py”, line 298, in recv_into
raise timeout(‘The read operation timed out’)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\requests\adapters.py”, line 449, in send
timeout=timeout
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\util\retry.py”, line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\packages\six.py”, line 686, in reraise
raise value
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\connectionpool.py”, line 386, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File “C:\Program Files\PsychoPy3\lib\site-packages\urllib3\connectionpool.py”, line 306, in _raise_timeout
raise ReadTimeoutError(self, url, “Read timed out. (read timeout=%s)” % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘gitlab.pavlovia.org’, port=443): Read timed out. (read timeout=2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\pavlovia_ui\project.py”, line 364, in onSyncButton
self.project.sync(infoStream=self.syncPanel.infoStream)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\projects\pavlovia.py”, line 640, in sync
self.repo = self.getRepo(forceRefresh=True, infoStream=infoStream)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\projects\pavlovia.py”, line 763, in getRepo
self.pavlovia = getCurrentSession().gitlab.projects.get(self.id)
File “C:\Program Files\PsychoPy3\lib\site-packages\gitlab\exceptions.py”, line 242, in wrapped_f
return f(*args, **kwargs)
File “C:\Program Files\PsychoPy3\lib\site-packages\gitlab\mixins.py”, line 49, in get
server_data = self.gitlab.http_get(path, **kwargs)
File “C:\Program Files\PsychoPy3\lib\site-packages\gitlab_init_.py”, line 517, in http_get
streamed=streamed, **kwargs)
File “C:\Program Files\PsychoPy3\lib\site-packages\gitlab_init_.py”, line 472, in http_request
result = self.session.send(prepped, timeout=timeout, **settings)
File “C:\Program Files\PsychoPy3\lib\site-packages\requests\sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “C:\Program Files\PsychoPy3\lib\site-packages\requests\adapters.py”, line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host=‘gitlab.pavlovia.org’, port=443): Read timed out. (read timeout=2)

I had used the search function to search through my account (so it was logged in on Pavlovia). The project appears in Gitlab, but not in my Pavlovia experiment dashboard.

At this point I am at a loss of what to do and was hoping some sort of virtual meeting would be possible to figure out what is going on and/or what my best course of action is. I have two experiments that I need to run and I can no longer make even small edits (like the number of repetitions for a loop) to my experiments. Please let me know!

For this one I’ve got a quick fix: logout and login again (inside of Builder). Then the issue is likely resolved