Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪲 Prevent stopped programs from executing #5225

Merged
merged 9 commits into from
Mar 12, 2024
Merged

Conversation

jpelay
Copy link
Member

@jpelay jpelay commented Mar 7, 2024

In Skulpt there really isn't a way to stop the execution of a program. If the program uses things like prompts for the input function, or sleep, then those promises are still somewhere in the JavaScript handler. Therefore, when you execute a new program while another one is still waiting for a promise to be fulfilled (i.e: waiting for user input through an ask prompt), when the new program finishes execution, the old one will continue its path.

To fix this I added a new field to sessionStorage which will have an id for the program being executed, and I edited Skulpt to pass the id of the program. Therefore, when an old program is being executed, its id will be different than the current one and therefore will finish its execution.

Fixes #5211

How to test

  • Go to level 14 and execute the TicTacToe adventure, fill the first ask.
  • With an ask prompt still open, switch to the Quizmaster tab and execute the program.
  • Only the Quizmaster program should be executed.

@jpelay jpelay marked this pull request as ready for review March 12, 2024 00:12
@jpelay
Copy link
Member Author

jpelay commented Mar 12, 2024

This is ready for review! I tried to solve to also bypass printing and exceptions, but ultimately was not able to! Remember to also review hedyorg/skulpt#2!

@Felienne
Copy link
Member

This is ready for review! I tried to solve to also bypass printing and exceptions, but ultimately was not able to! Remember to also review hedyorg/skulpt#2!

I will pick this PR up! Do I test the skulpt PR in the same way as this one? Should I pull both and test at once?

@Felienne Felienne self-assigned this Mar 12, 2024
@jpelay
Copy link
Member Author

jpelay commented Mar 12, 2024

This is ready for review! I tried to solve to also bypass printing and exceptions, but ultimately was not able to! Remember to also review hedyorg/skulpt#2!

I will pick this PR up! Do I test the skulpt PR in the same way as this one? Should I pull both and test at once?

Only test this one! If this one works, approve both, since the files generated by Skulpt are also included here.

@Felienne
Copy link
Member

Felienne commented Mar 12, 2024

I tried the steps above (after running frontend and doing a hard refresh), but I still get the ...'s in view:

image

@jpelay
Copy link
Member Author

jpelay commented Mar 12, 2024

I tried the steps above (after running frontend and doing a hard refresh), but I still get the ...'s in view:

image

Yes, this happens because when there's an exception in the original program it fails. You have to answer the first ask of the tic tac toe program, with any number, and then switch to the other tab.

@Felienne
Copy link
Member

I tried the steps above (after running frontend and doing a hard refresh), but I still get the ...'s in view:
image

Yes, this happens because when there's an exception in the original program it fails. You have to answer the first ask of the tic tac toe program, with any number, and then switch to the other tab.

Ah got it! So we should just make sure to never throw exceptions anymore (which we want anyway) and it will be solved haha!

Copy link
Contributor

mergify bot commented Mar 12, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

Copy link
Contributor

mergify bot commented Mar 12, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 9a828f5 into main Mar 12, 2024
12 checks passed
@mergify mergify bot deleted the fix_stopping_program branch March 12, 2024 16:38
boryanagoncharenko pushed a commit that referenced this pull request Mar 13, 2024
In Skulpt there really isn't a way to stop the execution of a program. If the program uses things like prompts for the `input` function, or sleep, then those promises are still somewhere in the JavaScript handler. Therefore, when you execute a new program while another one is still waiting for a promise to be fulfilled (i.e: waiting for user input through an ask prompt), when the new program finishes execution, the old one will continue its path.

To fix this I added a new field to `sessionStorage` which will have an id for the program being executed, and I edited Skulpt to pass the id of the program. Therefore, when an old program is being executed, its id will be different than the current one and therefore will finish its execution.


Fixes #5211

**How to test**

* Go to level 14 and execute the TicTacToe adventure, fill the first ask.
* With an ask prompt still open, switch to the Quizmaster tab and execute the program.
* Only the Quizmaster program should be executed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🪲 Switching to another tab with an ask prompt open, causes the program to mix up
2 participants