Fix Plugin Scripts load twice on startup #102535
Merged
+3
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
await
on EditorPlugin #100750Thanks to @HolonProduction for helping fix this issue.!!
The issue was caused by the plugin script being loaded twice on startup when the same script is used in the plugin's
ready
method and as an autoload. Autoloads are created before plugins, triggering the first load. When the plugin is enabled, the script is loaded again withCACHE_MODE_IGNORE
, causing it to reload whileawait
calls are still running.I changed the cache mode to
CACHE_MODE_REUSE
when enabling plugins on editor startup (while the first scan is running).I tested this with the MRP from #100750, and as suggested by @HolonProduction, I also retested the MRP from #70667. Godot's startup process has changed quite a bit since this issue was first reported. Since #92667, scripts that reference resources can now load even before the first scan, allowing the project to load without any errors or warnings on the first startup without the
.godot
folder.I have kept
CACHE_MODE_IGNORE
when the editor is not in startup mode to prevent potential side effects.