GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(ssh): 丢弃失效运行记录后复用同目录服务 · pingdotgg/t3code@3af36fa

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/ssh/src
    • tunnel.test.ts
    • tunnel.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/ssh/src/tunnel.test.ts‎

Copy file name to clipboardExpand all lines: packages/ssh/src/tunnel.test.ts
+27-4Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ switch (args[1]) {
288288
);
289289
yield* fs.writeFileString(
290290
path.join(directory, "ps"),
291-
'#!/bin/sh\nif [ "$T3_FIXTURE_ZOMBIE" = "1" ]; then printf Z; else exec /bin/ps "$@"; fi\n',
291+
'#!/bin/sh\nfor arg do pid="$arg"; done\nif [ -n "$T3_FIXTURE_ZOMBIE_PID" ] && [ "$pid" = "$T3_FIXTURE_ZOMBIE_PID" ]; then printf Z; else exec /bin/ps "$@"; fi\n',
292292
{ mode: 0o700 },
293293
);
294-
let zombie = "0";
294+
let zombiePid = "";
295295
let readyPort = "41773";
296296
const localSsh = ChildProcessSpawner.make((command) => {
297297
assert.strictEqual(command._tag, "StandardCommand");
@@ -302,7 +302,7 @@ switch (args[1]) {
302302
env: {
303303
HOME: directory,
304304
PATH: `${directory}:/usr/bin:/bin`,
305-
T3_FIXTURE_ZOMBIE: zombie,
305+
T3_FIXTURE_ZOMBIE_PID: zombiePid,
306306
T3CODE_HOME: customHome,
307307
T3_FIXTURE_READY_PORT: readyPort,
308308
T3_FIXTURE_STATE_DIR: stateDir,
@@ -343,14 +343,37 @@ switch (args[1]) {
343343
yield* fs.readFileString(path.join(stateDir, "run-t3.sh")),
344344
"old runner stays intact",
345345
);
346-
zombie = "1";
346+
zombiePid = String(external.pid);
347347
readyPort = "41774";
348348
assert.deepEqual(yield* launch, { remotePort: 41774, remoteServerKind: "managed" });
349349
assert.strictEqual(
350350
(yield* fs.readFileString(path.join(stateDir, "server-home"))).trim(),
351351
customHome,
352352
);
353353
assert.isTrue(yield* external.isRunning);
354+
355+
// A rejected runtime PID must not hide a live sibling on the selected home.
356+
const sibling = yield* realSpawner.spawn(
357+
ChildProcess.make(process.execPath, [
358+
"-e",
359+
"process.stdin.resume()",
360+
"--",
361+
"serve",
362+
"--host",
363+
"127.0.0.1",
364+
"--port",
365+
"41775",
366+
]),
367+
);
368+
const siblingDir = path.join(directory, ".t3/ssh-launch", "sibling");
369+
yield* fs.makeDirectory(siblingDir, { recursive: true });
370+
yield* fs.writeFileString(path.join(siblingDir, "managed"), "managed");
371+
yield* fs.writeFileString(path.join(siblingDir, "pid"), String(sibling.pid));
372+
yield* fs.writeFileString(path.join(siblingDir, "port"), "41775");
373+
yield* fs.writeFileString(path.join(siblingDir, "server-home"), customHome);
374+
readyPort = "41775";
375+
assert.deepEqual(yield* launch, { remotePort: 41775, remoteServerKind: "external" });
376+
assert.isTrue(yield* sibling.isRunning);
354377
}).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
355378
);
356379

Collapse file

‎packages/ssh/src/tunnel.ts‎

Copy file name to clipboardExpand all lines: packages/ssh/src/tunnel.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ if [ -n "$DEFAULT_RUNTIME_INFO" ]; then
737737
DEFAULT_RUNTIME_PID="\${DEFAULT_RUNTIME_INFO%% *}"
738738
DEFAULT_REMOTE_PORT="\${DEFAULT_RUNTIME_INFO#* }"
739739
if ! server_running "$DEFAULT_RUNTIME_PID"; then
740+
DEFAULT_RUNTIME_INFO=""
740741
DEFAULT_RUNTIME_PID=""
741742
DEFAULT_REMOTE_PORT=""
742743
fi

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.