Skip to content
TypeScript

fix(ssh): record the archive lock owner's real PID (#14598)

Guillermo Casanova584af5af4526
diff --git a/packages/ssh/src/tunnel.test.ts b/packages/ssh/src/tunnel.test.ts
index f7f46926ddf..001852f98da 100644
--- a/packages/ssh/src/tunnel.test.ts
+++ b/packages/ssh/src/tunnel.test.ts
@@ -232,6 +232,12 @@ describe("ssh tunnel scripts", () => {
assert.notInclude(script, "npx");
});
+ it("embeds the runner in the launch script byte for byte", () => {
+ const runner = buildRemoteT3RunnerScript(ARCHIVE);
+ assert.include(runner, 'printf \'%s\\n\' "$$" > "$T3_LOCK/pid.tmp"');
+ assert.include(buildRemoteLaunchScript(ARCHIVE), runner);
+ });
+
it("uses the remote t3 runner for launch and pairing scripts", () => {
const stateKey = "711bc738002d72fd";
const launch = SshTunnel.buildRemoteLaunchScript(ARCHIVE);
diff --git a/packages/ssh/src/tunnel.ts b/packages/ssh/src/tunnel.ts
index 6d70e381c04..c13e8d3768f 100644
--- a/packages/ssh/src/tunnel.ts
+++ b/packages/ssh/src/tunnel.ts
@@ -240,7 +240,8 @@ function applyScriptPlaceholders(
): string {
let result = template;
for (const [token, value] of Object.entries(replacements)) {
- result = result.replaceAll(`@@${token}@@`, value);
+ // A replacer function keeps `$$` and other `$` patterns in the value literal.
+ result = result.replaceAll(`@@${token}@@`, () => value);
}
return result;
}