Skip to content

Remove reloading difference async and sync loading #4252

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

Closed

Conversation

TPGamesNL
Copy link
Member

Description

The issue in #4246 happens because async reloading is different from normal reloading. In normal reloading, the script is first unloaded, then it is loaded. In async reloading, the script is first loaded, then the old version is unloaded.

This behaviour was chosen because the server does not halt during async reloading and having the script unload first would mean there is a timeframe where the script is not running, and apparently this was unwanted behaviour.

In this PR I changed the async reloading behaviour, so that it unloads scripts first, then loads them (same as sync reloading).
This fixes the issue, but the disadvantage of this is that during script reloading commands or functions in the reloading scripts aren't available.


Target Minecraft Versions: any
Requirements: none
Related Issues: #4246

@TPGamesNL TPGamesNL added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Aug 7, 2021
@Moderocky
Copy link
Member

Would it be possible to add a config option to choose which to use? I can imagine some people will want it the other way (to prevent there being a window when some important function isn't running.)

@TPGamesNL
Copy link
Member Author

Would it be possible to add a config option to choose which to use? I can imagine some people will want it the other way (to prevent there being a window when some important function isn't running.)

While it would be possible, I don't think it's a good idea, as that'd introduce the function reloading bug again if that option is enabled. If there is some important function they want to keep available at all times, they wouldn't even be able to reload it because of the bug.

Technically, the issue this PR introduces is also an issue for sync reloading, but it's only visible if the function call happens during reloading (so probably on another thread).

I could also make an exception for functions by making the new function overwrite the old version, but this would only work for functions. For commands, this wouldn't work. I think it would be better to make all of this stuff unavailable during reloading, but I'd like some opinions on it.

@APickledWalrus
Copy link
Member

After some discussion with TP, we're going to incorporate this PR into the Structure API at #4108

While this PR adds the disadvantage that during script reloading commands or functions in the reloading scripts aren't available, we have decided that it would be better for us to fix async script loading for now and focus on enhancing it at a later time.

@APickledWalrus APickledWalrus mentioned this pull request Jun 12, 2022
APickledWalrus added a commit that referenced this pull request Jun 12, 2022
@TPGamesNL TPGamesNL deleted the fix/async-reloading-functions branch August 15, 2022 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants