Fix review findings in dev sharing

- `auth pairing url` resolved the state directory with the same flag
  heuristic the command exists to hide, so without --dev-url it read
  `userdata` while `bun run dev` writes to `dev`. It then minted into the
  wrong database and printed a URL the live server rejects with
  `invalid_credential`. It now searches both state directories and issues
  against whichever one the running server actually uses.
- A server killed with SIGKILL leaves `server-runtime.json` behind, and
  that was taken as proof it was still up. Verify the recorded pid is
  alive before minting.
- `--dry-run --share` replaced and then tore down the port's existing
  tailscale mapping. Dry run now returns before the share block.

deriveServerPaths takes an optional explicit stateDir for callers that
have already located a running server and must target it exactly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Theo BrowneandClaude Opus 5 committed 2026-07-24 17:15:38 -07:00
1 parent 9b1a64e4a9
commit 36fe3b31a3
8 files changed
+176 -39

No files matched your search

+28
View File
@@ -620,6 +620,34 @@ it.layer(NodeServices.layer)("dev-runner", (it) => {
});
});
// `tailscale serve` config outlives the process, so a dry run that shared
// would replace and then tear down whatever mapping the port already had.
it.effect("spawns nothing when --dry-run is combined with --share", () => {
let spawnCount = 0;
const spawnerLayer = Layer.succeed(
ChildProcessSpawner.ChildProcessSpawner,
ChildProcessSpawner.make(() => {
spawnCount += 1;
return Effect.succeed(mockProcess(0));
}),
);
return Effect.gen(function* () {
yield* runDevRunnerWithInput({
...devServerInput,
mode: "dev",
port: undefined,
dryRun: true,
share: true,
}).pipe(
Effect.provide(Layer.mergeAll(emptyConfigLayer, netServiceLayer, spawnerLayer)),
Effect.provideService(HostProcessPlatform, "linux"),
);
assert.equal(spawnCount, 0);
});
});
it.effect("reports non-zero exits without manufacturing a cause", () => {
const spawnerLayer = Layer.succeed(
ChildProcessSpawner.ChildProcessSpawner,
+7 -4
View File
@@ -581,6 +581,13 @@ export function runDevRunnerWithInput(input: DevRunnerCliInput) {
`[dev-runner] mode=${input.mode} source=${source}${selectionSuffix} serverPort=${String(env.T3CODE_PORT)} webPort=${String(env.PORT)} baseDir=${baseDir}`,
);
// Before the share block: --dry-run only resolves and prints. Sharing would
// replace, then tear down, whatever mapping the port already had — a
// surprising side effect from a command documented as inert.
if (input.dryRun) {
return;
}
const sharedWebPort = BASE_WEB_PORT + webOffset;
if (input.share) {
if (input.mode === "dev:server") {
@@ -630,10 +637,6 @@ export function runDevRunnerWithInput(input: DevRunnerCliInput) {
}
}
if (input.dryRun) {
return;
}
const spawnCommand = yield* resolveSpawnCommand(
"vp",
[...MODE_ARGS[input.mode], ...input.runArgs],