Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ async function runTerminalHostRoundTrip({
const scratch = mkdtempSync(scratchPrefix)
const socketPath = join(scratch, 'd.sock')
const tokenPath = join(scratch, 'token')
const env = { ...process.env, ORCA_USER_DATA_PATH: join(scratch, 'user-data') }
// POSIX sh so the probe's arithmetic does not depend on the builder's login shell (e.g. fish).
const env = { ...process.env, SHELL: '/bin/sh', ORCA_USER_DATA_PATH: join(scratch, 'user-data') }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Stability & Availability · Heavy lift

Isolate the probe from shell startup files.

The daemon launches sh with -l in src/main/daemon/pty-subprocess/shell-launch-plan.ts, Line 220. It can therefore read the builder’s .profile and ENV file. (raw.githubusercontent.com)

If .profile executes fish, the probe runs the command in fish again and packaging can time out. Disable startup files for the probe while retaining the real PTY round trip.

delete env.ELECTRON_RUN_AS_NODE
const daemon = spawn(
command[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'n
import { createRequire } from 'node:module'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

const require = createRequire(import.meta.url)
const { runTerminalHostRoundTrip } = require('./verify-packaged-daemon-entry.cjs')
Expand All @@ -15,6 +15,7 @@ describe.skipIf(process.platform === 'win32')('terminal host round trip', () =>
})

afterEach(() => {
vi.unstubAllEnvs()
rmSync(root, { recursive: true, force: true })
})

Expand All @@ -27,6 +28,7 @@ describe.skipIf(process.platform === 'win32')('terminal host round trip', () =>
"const net = require('node:net'), fs = require('node:fs')",
'const arg = (name) => process.argv[process.argv.indexOf(name) + 1]',
`fs.writeFileSync(${JSON.stringify(join(root, 'pid'))}, String(process.pid))`,
`fs.writeFileSync(${JSON.stringify(join(root, 'shell'))}, process.env.SHELL)`,
`net.createServer(${onConnection}).listen(arg('--socket'), () => fs.writeFileSync(arg('--token'), 'tok'))`
].join('\n')
)
Expand Down Expand Up @@ -80,8 +82,10 @@ describe.skipIf(process.platform === 'win32')('terminal host round trip', () =>
}
})
}`)
vi.stubEnv('SHELL', '/usr/bin/fish')
const result = await roundTrip(entry, 1_500)
expect(result.error).toBe(null)
expect(readFileSync(join(root, 'shell'), 'utf8')).toBe('/bin/sh')
expect(result.daemonAlive).toBe(false)
expect(result.scratchDirs).toEqual([])
const messages = readFileSync(messagesPath, 'utf8').trim().split('\n').map(JSON.parse)
Expand Down
Loading