Skip to content

fix(control): serialize OSCQuery boot and prevent socket accumulation - #738

Merged
CaYatur merged 1 commit into
mainfrom
fix/osc-query-port-accumulation
Oct 11, 2026
Merged

CaYatur merged 1 commit into
mainfrom
fix/osc-query-port-accumulation

Conversation

@CaYatur

@CaYatur CaYatur commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes socket and port accumulation when OSC server synchronization is triggered in rapid succession.

  • Promise Queue & Epoch Invalidation: Serialized Query.start() and Query.stop() in osc-query.js through a Promise tail and generation counter (epoch).
  • Socket Tracking & Cleanup: All mDNS sockets are tracked in a set and closed upon halt(). Late bind callbacks from superseded epochs close their socket immediately instead of lingering.
  • Connection Draining: closeHttp() now invokes httpServer.closeAllConnections() to terminate active/idle keep-alive connections cleanly.
  • Agentless Probes: localhostIsOurs() uses agent: false to avoid reusing connections destined for a shutting-down server.
  • Race Condition Guard: syncOscServer in main.js discards stale promises when gen !== oscInGen.
  • Unit Tests: Added regression test in tests/osc-in.test.js ensuring concurrent starts leave only 1 socket and cleanly release previous ports. All 2981 unit tests pass.

Co-authored-by: caganturgut 271973834+caganturgut@users.noreply.github.com

When OSC server sync is triggered repeatedly or in rapid succession,
OSCQuery and mDNS sockets could be left listening concurrently on multiple
candidate ports.

Serialize OSCQuery start and stop through a promise queue with epoch
invalidation, close lingering HTTP connections via closeAllConnections,
ensure probe requests do not reuse closing keep-alive sockets, and track
all mDNS sockets so none remain open across restarts.

Co-authored-by: caganturgut <271973834+caganturgut@users.noreply.github.com>
@CaYatur
CaYatur merged commit aa2fa9d into main Oct 11, 2026
5 checks passed
@CaYatur
CaYatur deleted the fix/osc-query-port-accumulation branch October 11, 2026 19:16
@cayadraft

cayadraft Bot commented Oct 11, 2026

Copy link
Copy Markdown

@CaYatur

CaYaDraft — pull request

Summary
This pull request fixes socket and port accumulation issues in the OSC server by serializing query operations through a Promise queue and generation counter. It ensures that stale sockets are cleaned up immediately, active connections are drained properly, and race conditions during rapid synchronization are prevented.

Files

  • README.md, README.tr.md, ROADMAP.md (documentation updates)
  • src/main/main.js (race condition guard in syncOscServer)
  • src/main/osc-query.js (Promise queue, epoch tracking, socket cleanup)
  • tests/osc-in.test.js (regression test for concurrent starts)

Note
Nothing blocking is visible from the text.


Stopping here. I will not merge, push, or change this pull request until you ask.

/caya explain describes the diff. /caya plan previews the next edit. /caya revise adds a commit.

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