fix(scripts): generate:default-highscore starts its own dev server - #97
Merged
Conversation
It imported DEV_SERVER_URL from run-balancing-telemetry.mjs but never started
anything. planLevels() spins up a server for route planning and stops it
again, so by the time the bot phase ran there was nothing listening: every
attempt died on ERR_CONNECTION_REFUSED and the qualify loop reported "browser
appears dead: 3 consecutive fully-crashed batches" — three batches and
several minutes after the actual cause, naming the wrong thing entirely. It
only worked when someone happened to have a dev server already up, which is
why it went unnoticed.
This is the same assumption DEV_SERVER_URL's own comment records having
already broken single-player SSH lanes for the sibling script, where a remote
invocation got ERR_CONNECTION_REFUSED on every attempt, wrote its aggregate
and exited zero. The sibling was fixed by calling ensureDevServer per phase;
the generator never got that fix.
New exported devServerOptions(label) so both scripts resolve the server
contract from one place. Exported as a function rather than as the two
constants because CODEENSTEIN_DEV_URL ("use that server, never stop it") and
CODEENSTEIN_TELEMETRY_DEV_PORT ("start our own here") only mean the right
thing together.
Released via a process "exit" handler rather than a finally: the qualify loop
throws, and main() also process.exit(1)s on a partial set, so a finally would
cover the first and be skipped by the second. Safe as a sync handler because
stop() is child.kill. Does not cover SIGTERM, and the comment says so rather
than implying otherwise.
Verified with no server running, which is the case that failed:
ERR_CONNECTION_REFUSED went 12+ -> 0, "[highscore] starting vite on :5199"
now appears, and :5199 is free again afterwards. Additive to
run-balancing-telemetry.mjs so it does not conflict with the open #96.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while regenerating the default highscores:
npm run generate:default-highscorecannot run on its own. It importsDEV_SERVER_URLfromrun-balancing-telemetry.mjsbut never starts a server.planLevels()spins one up for route planning and stops it again, so by the time the bot phase ran there was nothing listening. Every attempt died onERR_CONNECTION_REFUSED, and the qualify loop reported:— three batches and several minutes after the actual cause, naming the wrong thing entirely. It only ever worked when someone happened to have a dev server already up, which is why it went unnoticed.
This exact assumption has bitten before
DEV_SERVER_URL's own comment records it:The sibling was fixed by calling
ensureDevServerper phase. The generator never got that fix.What changed
devServerOptions(label)so both scripts resolve the server contract from one place. Exported as a function rather than the two constants, becauseCODEENSTEIN_DEV_URL("use that server, never stop it") andCODEENSTEIN_TELEMETRY_DEV_PORT("start our own here") only mean the right thing together — taking one and forgetting the other is the bug waiting to happen.ensureDevServer(devServerOptions("highscore"))and navigates to its URL.Teardown detail worth a look in review
Released via a
process.on("exit")handler, not afinally. The qualify loop throws on a dead browser, andmain()alsoprocess.exit(1)s on a partial set — afinallycovers the first and is skipped by the second, so neither alone is enough.Safe as a synchronous handler because
stop()ischild.kill(devServer.mjs); an async teardown would silently not run there. It does not cover SIGTERM/Ctrl-C, and the comment says so rather than implying otherwise.Leaking matters more than it looks: a stale vite on
:5199means the next run finds it already answering, "reuses" it, and quietly plays a build from before whatever change prompted the re-run — which reads as bad data rather than as a leaked process.Verification
Ran it with no server up, which is the case that failed:
ERR_CONNECTION_REFUSED: 12+ → 0[highscore] starting vite on :5199now appears:5199free again after the run2,927 src tests, 532 script tests. The change to
run-balancing-telemetry.mjsis purely additive so it doesn't conflict with the open #96.No highscore data is committed here — the regeneration itself turned out to be churn (the new board scored lower, within the old board's own 6251-point spread), so
defaultHighscore.tsis untouched.