Skip to content

Commit 5375008

Browse files
authored
refactor: finish companion tunnel naming (#446)
1 parent d8c058e commit 5375008

13 files changed

Lines changed: 155 additions & 91 deletions

rslib.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default defineConfig({
3131
selectors: 'src/selectors.ts',
3232
finders: 'src/finders.ts',
3333
bin: 'src/bin.ts',
34-
'metro-companion': 'src/metro-companion.ts',
34+
'companion-tunnel': 'src/companion-tunnel.ts',
3535
daemon: 'src/daemon.ts',
3636
'update-check-entry': 'src/utils/update-check-entry.ts',
3737
},

src/__tests__/client-companion-tunnel-worker.test.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,18 @@ test('metro companion worker proxies websocket frames to the local upstream serv
350350

351351
const companion = spawn(
352352
process.execPath,
353-
['--experimental-strip-types', 'src/metro-companion.ts', '--agent-device-run-metro-companion'],
353+
['--experimental-strip-types', 'src/companion-tunnel.ts', '--agent-device-run-metro-companion'],
354354
{
355355
cwd: process.cwd(),
356356
env: {
357357
...process.env,
358-
AGENT_DEVICE_METRO_COMPANION_SERVER_BASE_URL: `http://127.0.0.1:${bridgePort}`,
359-
AGENT_DEVICE_METRO_COMPANION_BEARER_TOKEN: 'test-token',
360-
AGENT_DEVICE_METRO_COMPANION_LOCAL_BASE_URL: `http://127.0.0.1:${upstreamPort}`,
361-
AGENT_DEVICE_METRO_COMPANION_REGISTER_PATH: '/api/metro/companion/register',
362-
AGENT_DEVICE_METRO_COMPANION_SCOPE_TENANT_ID: 'tenant-1',
363-
AGENT_DEVICE_METRO_COMPANION_SCOPE_RUN_ID: 'run-1',
364-
AGENT_DEVICE_METRO_COMPANION_SCOPE_LEASE_ID: 'lease-1',
358+
AGENT_DEVICE_COMPANION_TUNNEL_SERVER_BASE_URL: `http://127.0.0.1:${bridgePort}`,
359+
AGENT_DEVICE_COMPANION_TUNNEL_BEARER_TOKEN: 'test-token',
360+
AGENT_DEVICE_COMPANION_TUNNEL_LOCAL_BASE_URL: `http://127.0.0.1:${upstreamPort}`,
361+
AGENT_DEVICE_COMPANION_TUNNEL_REGISTER_PATH: '/api/metro/companion/register',
362+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_TENANT_ID: 'tenant-1',
363+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_RUN_ID: 'run-1',
364+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_LEASE_ID: 'lease-1',
365365
},
366366
stdio: ['ignore', 'pipe', 'pipe'],
367367
},
@@ -502,18 +502,18 @@ test('metro companion worker reconnects after the bridge closes immediately afte
502502

503503
const companion = spawn(
504504
process.execPath,
505-
['--experimental-strip-types', 'src/metro-companion.ts', '--agent-device-run-metro-companion'],
505+
['--experimental-strip-types', 'src/companion-tunnel.ts', '--agent-device-run-metro-companion'],
506506
{
507507
cwd: process.cwd(),
508508
env: {
509509
...process.env,
510-
AGENT_DEVICE_METRO_COMPANION_SERVER_BASE_URL: `http://127.0.0.1:${bridgePort}`,
511-
AGENT_DEVICE_METRO_COMPANION_BEARER_TOKEN: 'test-token',
512-
AGENT_DEVICE_METRO_COMPANION_LOCAL_BASE_URL: `http://127.0.0.1:${localPort}`,
513-
AGENT_DEVICE_METRO_COMPANION_REGISTER_PATH: '/api/metro/companion/register',
514-
AGENT_DEVICE_METRO_COMPANION_SCOPE_TENANT_ID: 'tenant-1',
515-
AGENT_DEVICE_METRO_COMPANION_SCOPE_RUN_ID: 'run-1',
516-
AGENT_DEVICE_METRO_COMPANION_SCOPE_LEASE_ID: 'lease-1',
510+
AGENT_DEVICE_COMPANION_TUNNEL_SERVER_BASE_URL: `http://127.0.0.1:${bridgePort}`,
511+
AGENT_DEVICE_COMPANION_TUNNEL_BEARER_TOKEN: 'test-token',
512+
AGENT_DEVICE_COMPANION_TUNNEL_LOCAL_BASE_URL: `http://127.0.0.1:${localPort}`,
513+
AGENT_DEVICE_COMPANION_TUNNEL_REGISTER_PATH: '/api/metro/companion/register',
514+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_TENANT_ID: 'tenant-1',
515+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_RUN_ID: 'run-1',
516+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_LEASE_ID: 'lease-1',
517517
},
518518
stdio: ['ignore', 'pipe', 'pipe'],
519519
},
@@ -610,19 +610,19 @@ test('metro companion worker exits after its state file is removed', async () =>
610610

611611
const companion = spawn(
612612
process.execPath,
613-
['--experimental-strip-types', 'src/metro-companion.ts', '--agent-device-run-metro-companion'],
613+
['--experimental-strip-types', 'src/companion-tunnel.ts', '--agent-device-run-metro-companion'],
614614
{
615615
cwd: process.cwd(),
616616
env: {
617617
...process.env,
618-
AGENT_DEVICE_METRO_COMPANION_SERVER_BASE_URL: `http://127.0.0.1:${bridgePort}`,
619-
AGENT_DEVICE_METRO_COMPANION_BEARER_TOKEN: 'test-token',
620-
AGENT_DEVICE_METRO_COMPANION_LOCAL_BASE_URL: `http://127.0.0.1:${localPort}`,
621-
AGENT_DEVICE_METRO_COMPANION_REGISTER_PATH: '/api/metro/companion/register',
622-
AGENT_DEVICE_METRO_COMPANION_SCOPE_TENANT_ID: 'tenant-1',
623-
AGENT_DEVICE_METRO_COMPANION_SCOPE_RUN_ID: 'run-1',
624-
AGENT_DEVICE_METRO_COMPANION_SCOPE_LEASE_ID: 'lease-1',
625-
AGENT_DEVICE_METRO_COMPANION_STATE_PATH: statePath,
618+
AGENT_DEVICE_COMPANION_TUNNEL_SERVER_BASE_URL: `http://127.0.0.1:${bridgePort}`,
619+
AGENT_DEVICE_COMPANION_TUNNEL_BEARER_TOKEN: 'test-token',
620+
AGENT_DEVICE_COMPANION_TUNNEL_LOCAL_BASE_URL: `http://127.0.0.1:${localPort}`,
621+
AGENT_DEVICE_COMPANION_TUNNEL_REGISTER_PATH: '/api/metro/companion/register',
622+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_TENANT_ID: 'tenant-1',
623+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_RUN_ID: 'run-1',
624+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_LEASE_ID: 'lease-1',
625+
AGENT_DEVICE_COMPANION_TUNNEL_STATE_PATH: statePath,
626626
},
627627
stdio: ['ignore', 'pipe', 'pipe'],
628628
},
@@ -649,7 +649,7 @@ test('metro companion worker exits after its state file is removed', async () =>
649649
assert.equal(exit.code, 0, `unexpected worker stderr: ${stderr}`);
650650
});
651651

652-
test('metro companion worker exits immediately when its state file is already missing', async () => {
652+
test('companion tunnel entrypoint reads neutral env and exits when state file is missing', async () => {
653653
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-metro-companion-worker-'));
654654
const statePath = path.join(tempRoot, 'missing-metro-companion.json');
655655
cleanupTasks.push(async () => {
@@ -658,19 +658,19 @@ test('metro companion worker exits immediately when its state file is already mi
658658

659659
const companion = spawn(
660660
process.execPath,
661-
['--experimental-strip-types', 'src/metro-companion.ts', '--agent-device-run-metro-companion'],
661+
['--experimental-strip-types', 'src/companion-tunnel.ts', '--agent-device-run-metro-companion'],
662662
{
663663
cwd: process.cwd(),
664664
env: {
665665
...process.env,
666-
AGENT_DEVICE_METRO_COMPANION_SERVER_BASE_URL: 'http://127.0.0.1:1',
667-
AGENT_DEVICE_METRO_COMPANION_BEARER_TOKEN: 'test-token',
668-
AGENT_DEVICE_METRO_COMPANION_LOCAL_BASE_URL: 'http://127.0.0.1:1',
669-
AGENT_DEVICE_METRO_COMPANION_REGISTER_PATH: '/api/metro/companion/register',
670-
AGENT_DEVICE_METRO_COMPANION_SCOPE_TENANT_ID: 'tenant-1',
671-
AGENT_DEVICE_METRO_COMPANION_SCOPE_RUN_ID: 'run-1',
672-
AGENT_DEVICE_METRO_COMPANION_SCOPE_LEASE_ID: 'lease-1',
673-
AGENT_DEVICE_METRO_COMPANION_STATE_PATH: statePath,
666+
AGENT_DEVICE_COMPANION_TUNNEL_SERVER_BASE_URL: 'http://127.0.0.1:1',
667+
AGENT_DEVICE_COMPANION_TUNNEL_BEARER_TOKEN: 'test-token',
668+
AGENT_DEVICE_COMPANION_TUNNEL_LOCAL_BASE_URL: 'http://127.0.0.1:1',
669+
AGENT_DEVICE_COMPANION_TUNNEL_REGISTER_PATH: '/api/metro/companion/register',
670+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_TENANT_ID: 'tenant-1',
671+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_RUN_ID: 'run-1',
672+
AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_LEASE_ID: 'lease-1',
673+
AGENT_DEVICE_COMPANION_TUNNEL_STATE_PATH: statePath,
674674
},
675675
stdio: ['ignore', 'pipe', 'pipe'],
676676
},

src/__tests__/client-metro-companion.test.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function assertCompanionSpawnTarget(): void {
4141
assert.ok(firstCall, 'expected runCmdDetached to be called');
4242
assert.equal(firstCall[0], process.execPath);
4343
assert.ok(
44-
firstCall[1].some((arg) => arg.includes('src/metro-companion.ts')),
44+
firstCall[1].some((arg) => arg.includes('src/companion-tunnel.ts')),
4545
`expected companion entry path in ${JSON.stringify(firstCall[1])}`,
4646
);
4747
assert.equal(firstCall[1].at(-1), '--agent-device-run-metro-companion');
@@ -62,7 +62,7 @@ test('companion ownership is profile-scoped and consumer-counted', async () => {
6262
pid === 111 ? 'start-111' : 'start-222',
6363
);
6464
vi.mocked(readProcessCommand).mockImplementation(
65-
() => `${process.execPath} src/metro-companion.ts --agent-device-run-metro-companion`,
65+
() => `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`,
6666
);
6767
vi.mocked(waitForProcessExit).mockResolvedValue(true);
6868
const killSpy = vi.spyOn(process, 'kill').mockImplementation(() => true);
@@ -161,7 +161,7 @@ test('launchUrl changes force a companion respawn for the same profile', async (
161161
pid === 333 ? 'start-333' : 'start-444',
162162
);
163163
vi.mocked(readProcessCommand).mockImplementation(
164-
() => `${process.execPath} src/metro-companion.ts --agent-device-run-metro-companion`,
164+
() => `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`,
165165
);
166166
vi.mocked(waitForProcessExit).mockResolvedValue(true);
167167
const killSpy = vi.spyOn(process, 'kill').mockImplementation(() => true);
@@ -212,8 +212,8 @@ test('metro and React DevTools companions use distinct profile state paths', asy
212212
);
213213
vi.mocked(readProcessCommand).mockImplementation((pid) =>
214214
pid === 888
215-
? `${process.execPath} src/metro-companion.ts --agent-device-run-react-devtools-companion`
216-
: `${process.execPath} src/metro-companion.ts --agent-device-run-metro-companion`,
215+
? `${process.execPath} src/companion-tunnel.ts --agent-device-run-react-devtools-companion`
216+
: `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`,
217217
);
218218

219219
const profileKey = '/tmp/shared-remote.json';
@@ -251,6 +251,39 @@ test('metro and React DevTools companions use distinct profile state paths', asy
251251
}
252252
});
253253

254+
test('spawned companion uses neutral env names', async () => {
255+
const projectRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-companion-env-'));
256+
try {
257+
vi.mocked(runCmdDetached).mockReturnValueOnce(999);
258+
vi.mocked(readProcessStartTime).mockReturnValue('start-999');
259+
vi.mocked(readProcessCommand).mockReturnValue(
260+
`${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`,
261+
);
262+
263+
await ensureMetroCompanion({
264+
projectRoot,
265+
serverBaseUrl: 'https://bridge.example.test',
266+
bearerToken: 'token',
267+
localBaseUrl: 'http://127.0.0.1:8081',
268+
bridgeScope: TEST_BRIDGE_SCOPE,
269+
launchUrl: 'myapp://open',
270+
env: {},
271+
});
272+
273+
const env = vi.mocked(runCmdDetached).mock.calls[0]?.[2]?.env;
274+
assert.equal(env?.AGENT_DEVICE_COMPANION_TUNNEL_SERVER_BASE_URL, 'https://bridge.example.test');
275+
assert.equal(env?.AGENT_DEVICE_COMPANION_TUNNEL_BEARER_TOKEN, 'token');
276+
assert.equal(env?.AGENT_DEVICE_COMPANION_TUNNEL_LOCAL_BASE_URL, 'http://127.0.0.1:8081');
277+
assert.equal(env?.AGENT_DEVICE_COMPANION_TUNNEL_LAUNCH_URL, 'myapp://open');
278+
assert.equal(env?.AGENT_DEVICE_COMPANION_TUNNEL_REGISTER_PATH, '/api/metro/companion/register');
279+
assert.equal(env?.AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_TENANT_ID, 'tenant-1');
280+
assert.equal(env?.AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_RUN_ID, 'run-1');
281+
assert.equal(env?.AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_LEASE_ID, 'lease-1');
282+
} finally {
283+
fs.rmSync(projectRoot, { recursive: true, force: true });
284+
}
285+
});
286+
254287
test('legacy state without bridge scope is stopped before respawn', async () => {
255288
const projectRoot = fs.mkdtempSync(
256289
path.join(os.tmpdir(), 'agent-device-metro-companion-legacy-'),
@@ -263,7 +296,7 @@ test('legacy state without bridge scope is stopped before respawn', async () =>
263296
`${JSON.stringify({
264297
pid: 555,
265298
startTime: 'start-555',
266-
command: `${process.execPath} src/metro-companion.ts --agent-device-run-metro-companion`,
299+
command: `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`,
267300
serverBaseUrl: 'https://bridge.example.test',
268301
localBaseUrl: 'http://127.0.0.1:8081',
269302
tokenHash: 'legacy-token-hash',
@@ -275,7 +308,7 @@ test('legacy state without bridge scope is stopped before respawn', async () =>
275308
vi.mocked(isProcessAlive).mockReturnValue(true);
276309
vi.mocked(readProcessStartTime).mockReturnValue('start-555');
277310
vi.mocked(readProcessCommand).mockReturnValue(
278-
`${process.execPath} src/metro-companion.ts --agent-device-run-metro-companion`,
311+
`${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`,
279312
);
280313
vi.mocked(waitForProcessExit).mockResolvedValue(true);
281314
const killSpy = vi.spyOn(process, 'kill').mockImplementation(() => true);

src/cli/commands/connection-runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { resolveDaemonPaths } from '../../daemon/config.ts';
22
import { stopReactDevtoolsCompanion } from '../../client-react-devtools-companion.ts';
33
import { stopMetroTunnel } from '../../metro.ts';
44
import { resolveRemoteConfigProfile } from '../../remote-config.ts';
5-
import type { CompanionTunnelScope as MetroBridgeScope } from '../../client-companion-tunnel-contract.ts';
5+
import type { MetroBridgeScope } from '../../client-companion-tunnel-contract.ts';
66
import {
77
buildRemoteConnectionDaemonState,
88
hashRemoteConfigFile,

src/client-companion-tunnel-contract.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,31 @@ export const COMPANION_TUNNEL_RECONNECT_DELAY_MS = 1_000;
44
export const COMPANION_TUNNEL_LEASE_CHECK_INTERVAL_MS = 250;
55
export const WS_READY_STATE_OPEN = 1;
66

7-
export const ENV_COMPANION_TUNNEL_SERVER_BASE_URL = 'AGENT_DEVICE_METRO_COMPANION_SERVER_BASE_URL';
8-
export const ENV_COMPANION_TUNNEL_BEARER_TOKEN = 'AGENT_DEVICE_METRO_COMPANION_BEARER_TOKEN';
9-
export const ENV_COMPANION_TUNNEL_LOCAL_BASE_URL = 'AGENT_DEVICE_METRO_COMPANION_LOCAL_BASE_URL';
10-
export const ENV_COMPANION_TUNNEL_LAUNCH_URL = 'AGENT_DEVICE_METRO_COMPANION_LAUNCH_URL';
11-
export const ENV_COMPANION_TUNNEL_STATE_PATH = 'AGENT_DEVICE_METRO_COMPANION_STATE_PATH';
12-
export const ENV_COMPANION_TUNNEL_SCOPE_TENANT_ID = 'AGENT_DEVICE_METRO_COMPANION_SCOPE_TENANT_ID';
13-
export const ENV_COMPANION_TUNNEL_SCOPE_RUN_ID = 'AGENT_DEVICE_METRO_COMPANION_SCOPE_RUN_ID';
14-
export const ENV_COMPANION_TUNNEL_SCOPE_LEASE_ID = 'AGENT_DEVICE_METRO_COMPANION_SCOPE_LEASE_ID';
15-
export const ENV_COMPANION_TUNNEL_REGISTER_PATH = 'AGENT_DEVICE_METRO_COMPANION_REGISTER_PATH';
16-
export const ENV_COMPANION_TUNNEL_UNREGISTER_PATH = 'AGENT_DEVICE_METRO_COMPANION_UNREGISTER_PATH';
17-
export const ENV_COMPANION_TUNNEL_DEVICE_PORT = 'AGENT_DEVICE_METRO_COMPANION_DEVICE_PORT';
18-
export const ENV_COMPANION_TUNNEL_SESSION = 'AGENT_DEVICE_METRO_COMPANION_SESSION';
7+
export const ENV_COMPANION_TUNNEL_SERVER_BASE_URL = 'AGENT_DEVICE_COMPANION_TUNNEL_SERVER_BASE_URL';
8+
export const ENV_COMPANION_TUNNEL_BEARER_TOKEN = 'AGENT_DEVICE_COMPANION_TUNNEL_BEARER_TOKEN';
9+
export const ENV_COMPANION_TUNNEL_LOCAL_BASE_URL = 'AGENT_DEVICE_COMPANION_TUNNEL_LOCAL_BASE_URL';
10+
export const ENV_COMPANION_TUNNEL_LAUNCH_URL = 'AGENT_DEVICE_COMPANION_TUNNEL_LAUNCH_URL';
11+
export const ENV_COMPANION_TUNNEL_STATE_PATH = 'AGENT_DEVICE_COMPANION_TUNNEL_STATE_PATH';
12+
export const ENV_COMPANION_TUNNEL_SCOPE_TENANT_ID = 'AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_TENANT_ID';
13+
export const ENV_COMPANION_TUNNEL_SCOPE_RUN_ID = 'AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_RUN_ID';
14+
export const ENV_COMPANION_TUNNEL_SCOPE_LEASE_ID = 'AGENT_DEVICE_COMPANION_TUNNEL_SCOPE_LEASE_ID';
15+
export const ENV_COMPANION_TUNNEL_REGISTER_PATH = 'AGENT_DEVICE_COMPANION_TUNNEL_REGISTER_PATH';
16+
export const ENV_COMPANION_TUNNEL_UNREGISTER_PATH = 'AGENT_DEVICE_COMPANION_TUNNEL_UNREGISTER_PATH';
17+
export const ENV_COMPANION_TUNNEL_DEVICE_PORT = 'AGENT_DEVICE_COMPANION_TUNNEL_DEVICE_PORT';
18+
export const ENV_COMPANION_TUNNEL_SESSION = 'AGENT_DEVICE_COMPANION_TUNNEL_SESSION';
1919

2020
export type CompanionTunnelScope = {
2121
tenantId: string;
2222
runId: string;
2323
leaseId: string;
2424
};
2525

26+
export type MetroBridgeScope = CompanionTunnelScope;
27+
28+
export class MissingCompanionEnvError extends Error {
29+
override name = 'MissingCompanionEnvError';
30+
}
31+
2632
export type CompanionTunnelWorkerOptions = {
2733
serverBaseUrl: string;
2834
bearerToken: string;

src/client-companion-tunnel-worker.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
METRO_COMPANION_RUN_ARG,
1919
REACT_DEVTOOLS_COMPANION_RUN_ARG,
2020
WS_READY_STATE_OPEN,
21+
MissingCompanionEnvError,
2122
type CompanionTunnelWorkerOptions,
2223
} from './client-companion-tunnel-contract.ts';
2324
import type {
@@ -450,17 +451,23 @@ function readWorkerOptions(
450451
const bearerToken = env[ENV_COMPANION_TUNNEL_BEARER_TOKEN]?.trim();
451452
const localBaseUrl = env[ENV_COMPANION_TUNNEL_LOCAL_BASE_URL]?.trim();
452453
if (!serverBaseUrl || !bearerToken || !localBaseUrl) {
453-
throw new Error('Companion tunnel worker is missing required environment configuration.');
454+
throw new MissingCompanionEnvError(
455+
'Companion tunnel worker is missing required environment configuration.',
456+
);
454457
}
455458
const tenantId = env[ENV_COMPANION_TUNNEL_SCOPE_TENANT_ID]?.trim();
456459
const runId = env[ENV_COMPANION_TUNNEL_SCOPE_RUN_ID]?.trim();
457460
const leaseId = env[ENV_COMPANION_TUNNEL_SCOPE_LEASE_ID]?.trim();
458461
if (!tenantId || !runId || !leaseId) {
459-
throw new Error('Companion tunnel worker is missing required bridge scope configuration.');
462+
throw new MissingCompanionEnvError(
463+
'Companion tunnel worker is missing required bridge scope configuration.',
464+
);
460465
}
461466
const registerPath = env[ENV_COMPANION_TUNNEL_REGISTER_PATH]?.trim();
462467
if (!registerPath) {
463-
throw new Error('Companion tunnel worker is missing required register path configuration.');
468+
throw new MissingCompanionEnvError(
469+
'Companion tunnel worker is missing required register path configuration.',
470+
);
464471
}
465472
return {
466473
serverBaseUrl,
@@ -472,11 +479,11 @@ function readWorkerOptions(
472479
runId,
473480
leaseId,
474481
},
475-
launchUrl: env[ENV_COMPANION_TUNNEL_LAUNCH_URL]?.trim() || undefined,
476-
statePath: env[ENV_COMPANION_TUNNEL_STATE_PATH]?.trim() || undefined,
477-
unregisterPath: env[ENV_COMPANION_TUNNEL_UNREGISTER_PATH]?.trim() || undefined,
478-
devicePort: parseDevicePort(env[ENV_COMPANION_TUNNEL_DEVICE_PORT]),
479-
session: env[ENV_COMPANION_TUNNEL_SESSION]?.trim() || undefined,
482+
launchUrl: env[ENV_COMPANION_TUNNEL_LAUNCH_URL]?.trim(),
483+
statePath: env[ENV_COMPANION_TUNNEL_STATE_PATH]?.trim(),
484+
unregisterPath: env[ENV_COMPANION_TUNNEL_UNREGISTER_PATH]?.trim(),
485+
devicePort: parseDevicePort(env[ENV_COMPANION_TUNNEL_DEVICE_PORT]?.trim()),
486+
session: env[ENV_COMPANION_TUNNEL_SESSION]?.trim(),
480487
};
481488
}
482489

0 commit comments

Comments
 (0)