-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Debugger stops when loading scripts with invalid syntax #85699
Comments
We addon developers rely on the old behaviour, as we want to e.g. test via unit tests that loading a broken script does not break anything. However, currently, this just fails the CI build (this did not happen in 4.1 and prior). If it is not possible any longer to revert back to the old behaviour due to architectural reasons, a suggested workaround would be greatly appreciated. |
I'm not entirely sure why you would load syntactically broken scripts. Wouldn't just providing an empty But as a possible workaround, you could load the source code via the FileAccess API and then create the script object from that: var script := GDScript.new()
script.source_code = code_from_file
var err := script.reload() |
Related: godotengine/godot-proposals#8548 |
Note that this is in 4.1 as well, if those PRs are indeed the source of those changes (this also shows the importance of declaring what versions you are talking about when suggesting something is a regression, since unless this is caused by some other PR this behavior is in 4.1.3) |
This now work, I already tried it results in the same problem |
There a no issues when using v4.1.3.stable.official [f06b6836a] the load works without the debugger stoped. |
To bring more light into the issue here, an example project to show the problem.
vs
This breaks now the workflow, on Godot 4.2 the program is on hold via debugger break. |
I don't quite understand why you would need to load broken scripts on CI. Unit tests for your project should be testing for issues in your project's logic and behavior. Broken scripts are not that, they won't work because Godot itself won't be able to do anything with them. They will always trigger the debugger at runtime during test runs. What exactly is it that you're trying to test here? |
@YuriSizov you can write addons where users specify custom scripts. These scripts can be broken, though. In case they are, the plugin should not crash etc. but handle that gracefully. For this, e.g. I have written tests in my addon and the setup worked fine until 4.2 - I found a workaround though, which is to move the broken scripts outside the folder scanning of the unit test execution scope. While this is fine, other addon devs may stumble upon the same issue. Having a mechanism to at least toggle off the 'error throwing' of |
@YuriSizov as @bitbrain already wrote, I have no control what the user is testing. To report script errors during loading are very fine, but it should not end up in a debugger on hold. |
To add to my previous comment, as I forgot to mention it: Godot's design philosophy usually is to avoid throwing errors whenever possible (this is why e.g. GDScript does not support exceptions as control flow) - instead of crashing, we should always aim to 'continue' whenever possible. The behaviour in Godot 4.1.3 was okay, but looking at the issues linked above I understand why the contract on An alternative to this could be to have a new method called |
Just to be clear, the
So this seems to me like it behaves as intended. There's an error in the project, you asked for a stdout debugger, and you get that. It seems to me that you don't actually want a stdout debugger to interrupt the CI flow, so you maybe you shouldn't use I tested and without
|
@akien-mga i now -d is debug. |
Well, the problem here is that the debug mode is specifically to launch your scripts with a debugger attached. So with the bugs fixed in 4.2 this is now operating as expected and as designed. What you really need is some form of godotengine/godot-proposals#8548 with a way to retrieve errors after the fact. Something that #85544 is trying to accomplish. You made it work with the debug mode and the old behavior, but your workflow is based on something that wasn't working properly, so now that it is fixed, it doesn't work anymore. It's unfortunate, but it's always risky to commit to an implementation based on something unreliable. I would suggest opening a proposal for a proper solution in this situation. Not sure much can be done as a workaround for now without compromising on error reporting where it's supposed to work, i.e. under most other circumstances. |
@YuriSizov I never saw in the documentation that the debugger should hold the script while loading if it is invalid. Again, I have no problems with the errors showing up on load. That is a great improvement to see such errors. In my opinion, this is not correct, a debugger should only intervene in code that is currently being executed. |
Discussing of this issue with the GDScript team in our weekly meeting. A bisection of the issue would be appreciated, to know if the change that introduced this issue was intentional or not. |
I tested against all 4.2 builds, this issue was introduced in build v4.2.beta3.official.e8d57afae
v4.2.beta2 the test scene runs and loads the corrupted script without debugger stop.
On v4.2.beta3 the test scene runs and stops in the debugger at loading the corrupted script. |
That commit is unrelated to this change, it is a particle commit, so must be some other commit |
I just tested against official builds. |
Would need an actual bisect to find it specifically, but this is a good starting point |
I know, but I never setup a build environment to build the Godot editor from a specific commit. |
As much I don't want to add salt to the wound, I would highly encourage plugin developers to test their plugins against upcoming beta releases (or at minimum against release candidate releases) in order to prevent such situations. Nobody benefits from incompatibilities like this one. |
load()
introduced a regression and fails now by loading corrupted scripts
@adamscott I think it actually might be worth to have a dedicated 'future' branch building against specific godot nightly builds to verify regressions dynamically in addon repos. That is obviously more effort but worth it in the long run. I will discuss this privately with others. Offtopic over. |
I am testing the upcoming versions, as you can see here, it had unfortunately turned out in the past that quite often things are broken. I feel like I have to install a workaround in every major release because things have changed unpredictably. In this case, it's a side issue that I hadn't covered before. Especially the massive problems with the newly introduced caching and the .godot folder speak volumes. |
Godot version
v4.2.stable.official [46dc277]
System information
Windows 10
Issue description
I'm the developer of the GdUnit4 plugin and run into a regression issue since update to Godot 4.2.
My plugin provides a tool to mock scripts for testing purpose.
When i
load
a given script to mock by usingGDScript.load(<path>)
it produces now runtime errors when the script has some syntax errors.This breaks now my implementation and the Debugger stops during load on the script error. Before, it was just load the script without checking for syntax/script errors.
The
load
is now checking in addition for script errors, this is a major regression!Before I could just load any script also "broken" scripts.
Please roll this change back or provide a flag to enable/disable script syntax checking on load.
Steps to reproduce
res://tests/invaldScript.gd
The debugger now stops on the invalid script
Minimal reproduction project
n/a
The text was updated successfully, but these errors were encountered: