Skip to content

[lua] Fix error when closing unused socket - #13159

Merged
Simn merged 5 commits into
HaxeFoundation:developmentfrom
tobil4sk:fix/close-unused-socket
Nov 7, 2026
Merged

Simn merged 5 commits into
HaxeFoundation:developmentfrom
tobil4sk:fix/close-unused-socket

Conversation

@tobil4sk

@tobil4sk tobil4sk commented Nov 6, 2026

Copy link
Copy Markdown
Member

The test for #13031 had to have a guard for lua because it crashes when closing an unused socket. Now it is safe to call close on a socket that is unused, matching other targets.

@Simn

Simn commented Nov 7, 2026

Copy link
Copy Markdown
Member

If this can be null we should wrap the type in Null<LuaSocket> while we're at it.

Also did you check that the close function is the only place where this can happen?

@tobil4sk

tobil4sk commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

There are still other cases where you can cause an error by doing some operation that doesn't make sense on an unconnected or misconfigured socket. However, unlike close, what happens when you do that is quite inconsistent between targets (null exceptions, native exceptions, or nothing) and it would take more work to unify. In most of the cases it would probably be best to have proper haxe exceptions.

I mainly wanted to do this because there is already a test that wanted this behaviour and had to have an #if !lua guard.

@Simn
Simn merged commit e592de2 into HaxeFoundation:development Nov 7, 2026
51 checks passed
@tobil4sk
tobil4sk deleted the fix/close-unused-socket branch November 7, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants