CC: Tweaked

CC: Tweaked

65M Downloads

Unable to recover from invalid terminal redirect

Spacedestructor opened this issue ยท 6 comments

commented

Minecraft Version

1.20.1

Version

1.116.1

Details

I have noticed a regression after updating to 1.116.1, when i do something like for example
term.redirect(term)
term.redirect(term.native())
error("Test Error")
then it will error and say "term is not a recommended redirect target, try term.current() instead".
However this error points to term.redirect(term.native()) instead of error("Test Error") because calling term.redirect() in an attempt to fix a broken state the program has entered will trigger some internal check if im using a valid object and thus make it impossible to dynamically fix this.
In previous versions i was able to do this and it wouldnt complain as long as i didnt call any functions that interact with the terminal before redirecting.

commented

I should mention that if all 3 sample lines of code happen in the same scope, such as the same function for example the mod will properly handle this error but in my case the original invalid redirect is in a seperate function and scope as the later redirect and the error call, which makes the mod fail to correctly indicate the source of the error and also fail to point out the error as soon as the invalid redirect happens.
Since the invalid redirect in my program happened in a seperate function which is in a different scope then the code which attempts to redirect to a valid object it only triggers on the second redirect for some reason instead of imediatly and then point to the second redirect or if thats commented out to the error call instead.

commented

I have noticed a regression after updating to 1.116.1

Sorry, just to check, which version were you upgrading from where this worked? I'm not aware of any recent changes to the terminal code, but might have forgotten one!

commented

Would you also be able to clarify the exact code you're running and what error you're getting? When I run the code in the main issue, it errors on the first line (not on term.redirect(term.native())) as I'd expect:

term.redirect(term)
term.redirect(term.native())
error("Test Error")

An error reading "term is not a recommended window parent, try term.current() instead"

commented

I have noticed a regression after updating to 1.116.1

Sorry, just to check, which version were you upgrading from where this worked? I'm not aware of any recent changes to the terminal code, but might have forgotten one!

Its quiet a big jump, i cant find the mod right now but i do know that i changed from the last version which was uploaded to curseforge so probably at least a few months of changes happened all at once when i updated the mod.
As for the code, i github wont let me share files directly unfortunately for some reason right now but i have a slightly outdated version at https://github.com/Spacedestructor/Turtle-Remote-Control/tree/SourceLua.
in sumary startup.lua requires and runs Bot.lua which requires and runs Run.lua which among doing many things does require and run SetupMonitor.lua.
the main relevant changes between the versions is that instead of redirecting to the Monitor the script finds i accidentally had redirected to the terminal api class and that in my current version the error handling in startup.lua does include a redirect to the native terminal object.
the script runs fine until something tries to interact with the terminal and then it points to where im trying to redirect back to the native object, if i comment that out then it points to the error and only if i do comment out all custom error handling does it point to where i defined it incorrectly.
Also as stated before, if i run the relevant instructions for this error all directly in startup.lua as an example it does work correctly.
Only if i spread it out over multiple functions in multiple files does it eventually start pointing to wrong locations for the error.

commented

If you jumped from last Curseforge to Modrinth version that would be 1.113.1 to 1.116.1 jump, and looking at changelogs redirection logic was not changed in that version-span. (last possible change was over 2 years ago and many versions)

Any chance you could show us screenshots of actual errors you are encountering? and exactly what code are you running when error happens? It is kinda hard to piece back what is actually happening and what issue is from your explanation.

commented

If you jumped from last Curseforge to Modrinth version that would be 1.113.1 to 1.116.1 jump, and looking at changelogs redirection logic was not changed in that version-span. (last possible change was over 2 years ago and many versions)

Any chance you could show us screenshots of actual errors you are encountering? and exactly what code are you running when error happens? It is kinda hard to piece back what is actually happening and what issue is from your explanation.

I wish i would be able to show literally anything at all but for some reason github is acting up and doesnt let me attach any files, so i cant show the code directly as it is or screenshots of the error. the most i could do is copy and past the code over in to this text box but that becomes too confusing quickly to reasonably keep up with whats going on.