Skip to content

fix(process): refuse to start a second session process for one id - #32

Open
xepozz wants to merge 1 commit into
wippyai:masterfrom
xepozz:fix/session-registration-race
Open

fix(process): refuse to start a second session process for one id#32
xepozz wants to merge 1 commit into
wippyai:masterfrom
xepozz:fix/session-registration-race

Conversation

@xepozz

@xepozz xepozz commented Aug 24, 2026

Copy link
Copy Markdown

Found while tracing why a channel conversation was not appearing live in a Kickside UI. Not the cause of that, but a real race on the way.

The defect

src/process/session.lua claims the session name and throws the answer away:

process.registry.register("session." .. args.session_id)

process.registry.register reports whether the name was already taken. Discarding that means two spawns for one session id both proceed. Each opens its own writer, both append to the same conversation, and the process that lost the registration keeps serving a name that no longer routes to it — so everything it sends upstream goes nowhere, silently.

Why the caller cannot fix it

src/process/plugin.lua checks only its own in-memory map before spawning. A second caller — another plugin instance, a channel bridge, or any ensure-then-spawn path — has no way to observe the first. The registered name is the only authority, and this line is already claiming it.

The change

Ten lines: keep the result, and fail the start when the name is taken. That matches how the surrounding code already treats a session it cannot open (Failed to open session, Cannot open failed session).

Verification

make lint reports the same 22 pre-existing errors and 1 warning before and after the change, none of them in wippy.session.process:session. I could not run make test locally — the harness stops at failed to expand changeset: verified dependency evidence is unavailable during offline startup — so CI is the first real run.

Happy to add a regression test if you can point me at how to spawn two processes for one id inside the harness; nothing under test/ currently exercises the session process directly.

process.registry.register returns whether the name was taken, and the session
process discarded it. When two spawns race for one session id both processes
run: each opens its own writer, both append to the same conversation, and the
one that lost the registration keeps serving a name that no longer routes to
it, so its upstream updates go nowhere.

Callers cannot close this themselves. wippy.session.process:plugin checks only
its own in-memory map before spawning, so a second caller — another plugin
instance, a channel bridge, an ensure-then-spawn path — has no way to see the
first. The name is the only authority, and it is already being claimed here;
this just stops ignoring the answer.

Fails the start instead of continuing, matching how the surrounding code
handles a session it cannot open.
@xepozz
xepozz force-pushed the fix/session-registration-race branch from c5a17ed to 7799083 Compare August 24, 2026 15:52
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.

1 participant