PILOT option on Pavlovia create an unusable link

URL of experiment: Isotta Rigoni / test_online_experiment · GitLab

Description of the problem: I am using Psycopy2024 2.4; I have created a script, pushed it to Pavlovia and made it public. The project can be found at the link above . Once on Pavlovia, I switch the status of my project from INACTIVE to PILOTING and then I click on Pilot to generate the URL of the experiment. However, when I click on Pilot, it only opens a blank page that says “initialising…” (see figure). I don’t know why this is happening nor how to solve this.

I also tried to do the same thing with my other project (Sign in · GitLab, private) but when I click on Pilot, it generates a “403 Forbidden” page…is this because the project is not public?

Thank you a lot in advance!
Isotta

Regarding my second point, I am wondering whether the second project gives a 403 error because there are multiple folders inside the project, rather than just one?

Hello

Does this help? Wakefield's Daily Tips - #51 by wakecarter

Best wishes Jens

Hello,
thanks for redirecting me toward this amazing page.
I have used the Developer tools console and identified the error, that indeed was “Uncaught SyntaxError: Unexpected token ‘*’” at line 460, where the code was trying to import the library random: import * as random from ‘random’.

Therefore I removed all the import statements from all the .js files (retrieval_1.js at line 460, retrieval_1-legacy-browsers.js at line 454), saved, synched project with Pavlovia and piloted it.

However I still get the “initialising” white screen with the same error:
Uncaught SyntaxError: Unexpected token ‘*’ retrieval_1.js: 460

I don’t understand how this is possible, given that the line 460 has indeed been removed from my code (retrieval_1.js · master · Isotta Rigoni / test_online_experiment · GitLab).

Is it possible that it takes a while to update the code on pavlovia or do I need some extra synchronization step?

Thanks a lot in advance,
Isotta

1 Like

Hello @IRIO

Remove all import lines from your Python script or create code components that are set to Both instead of Auto → JS. If your program is running locally with the import commands, resync and run the experiment in an incognito tab or clear the browser cache. Your are probably running the old version from the browser’s cache.

As mentioned in @wakecarter’s tips, you should (almost) never edit the generated code.

Best wishes Jens

Hello @JeanBoelte,
thanks for following up on this issue. I have tried to set the code component to “Both” and it didn’t work. Then, I removed the import statement from the code component, saved the file, synched it and checked the retrieval_1.jf file and the line “import * as random from ‘random’;” was still there. How is this possible?
Indeed, even when I run it in an incognito widnwo it still gives me the same error at the same line (Uncaught SyntaxError: Unexpected token ‘*’)

(the “initialising” page is gone when I modify manually the js files… however, as you are suggesting not to do so, I am trying to look for another solution but the proposed ones do not seem to work in my case)

Hello @IRIO

You have to delete the import-command on the JS-side after setting it to Both?

Best wishes Jens

IRIO

16m

Sorry, maybe I didn’t explain myself well.
In Builder, I removed the import statement from the code component and, just to be on the safe side, set it to Both. I ran it locally and it worked. Then I synched it and piloted it online in an in cognito window… as it still gave the same error at the same line (Uncaught SyntaxError: Unexpected token ‘*’) I went back and checked the js file and indeed the line “import * as random from ‘random’;” was still there although I had removed the import statement from the code component… how is it possible?

Are you exporting html on sync?

I am sorry, I am not sure what you mean by this.
After doing the modifications in Builder, I synch by clicking on the icon below and indeed it creates one html and two js files…

What does “export html on synch” mean?

I am sorry for this… I really appreciate this help

This is export on sync. It can be turned off in experiment settings.

In that case I wonder if you can switched an Auto component importing random to a Python component, not realising that this only hides the JavaScript. Change it to both and delete the import statement on the JS side before switching back to Python (or leave it as Both).

Thank you so much, now it works.
However, once online it gives me an error linked to the function strip() ( * TypeError: display_word_1.strip is not a function)… should I go back to the code component-JS side and modify it to trim()?

Shouldn’t this be automatically done by the Auto->JS option?

Have a look here:

Hello @IRIO

yes, strip is not a JavaScript-function. Aparently, it not properly auto-translated. Your could also define a function in a Begin experiment tab to reduce the editing you have to do, see here Wakefield's Daily Tips - #27 by wakecarter.

Best wishes Jens

Hello, I have tried to define a helper function strip_text() like this in a code component of the “welcome_message” routine:

I replaced strip() with strip_text() in the code component of my trial routine, but I still get the error that " * TypeError: display_word_1.strip_text is not a function":

I don’t understand if there’s something else I should do to make sure that strip-text is retained for the whole duration of the experiment?

To use your strip_text function, type strip_text(display_word_1)

Of course, I feel so dumb :slight_smile:
Thanks again for all your help, the experiment is now running as it should!