Skip to content

proxy forgets packages if debuggee connects#346

Open
vvvrrooomm wants to merge 1 commit intoactboy168:masterfrom
vvvrrooomm:fix_listen_forgets_packages
Open

proxy forgets packages if debuggee connects#346
vvvrrooomm wants to merge 1 commit intoactboy168:masterfrom
vvvrrooomm:fix_listen_forgets_packages

Conversation

@vvvrrooomm
Copy link
Copy Markdown

this might fix #344

when lua-debug wait for a conencting debuggee, after the connection is accepted nothing happens. lua-debug should send queued packages in that case, as it does in the other case where lua-debug connects to the debuggee

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the on_accepted callback in extension/script/common/socket.lua to initialize a session and handle buffered writes. However, the added logic is unreachable due to an early return statement. Additionally, the code contains an undefined variable reference and an inappropriate use of assert that could lead to crashes; a refactored approach was suggested to correctly handle session initialization and buffer flushing.

Comment on lines +89 to +94
local ok = init_session(s)
assert(ok)
if writebuf ~= '' then
s:write(writebuf)
writebuf = ''
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The code added here is unreachable because of the return statement on line 88. Additionally, the variable s is undefined in this scope; it should be new_s. Finally, using assert(ok) is problematic here because init_session returns nil if a session already exists (e.g., if another client is already connected), which should result in rejecting the new connection rather than crashing the proxy.

To fix this, remove the return on line 88 and refactor the block as follows:

        function server:on_accepted(new_s)
            local ok = init_session(new_s)
            if ok then
                if writebuf ~= '' then
                    new_s:write(writebuf)
                    writebuf = ''
                end
            end
            return ok
        end

this might fix actboy168#344

when lua-debug wait for a conencting debuggee, after the connection is accepted nothing happens.
lua-debug should send queued packages in that case, as it does in the other case where lua-debug connects to the debuggee
@vvvrrooomm vvvrrooomm force-pushed the fix_listen_forgets_packages branch from 7565a9c to a387134 Compare April 7, 2026 05:32
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.

proxy forgets queued messages before debugee connects, when luade-bug listens for incoming debuggee connections

1 participant