perf(ssh): resolve node path concurrently with remote install state (#6952)
Run independent SSH relay bootstrap probes concurrently when the connection can safely support overlapping execs. Preserve the old sequential path for system SSH without reusable ControlMaster and for remotes that reject concurrent session channels.
This commit is contained in:
@@ -4,6 +4,7 @@ import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { SshConnection } from './ssh-connection'
|
||||
import { getRemoteHostPlatform } from './ssh-remote-platform'
|
||||
|
||||
const execCommandMock = vi.hoisted(() => vi.fn())
|
||||
|
||||
@@ -270,6 +271,66 @@ describe('resolveRemoteNodePath', () => {
|
||||
await expect(resolveRemoteNodePath(conn)).rejects.toThrow(/Node\.js not found/)
|
||||
})
|
||||
|
||||
it('keeps the default path-probe fallback for SSH session-limit-shaped errors', async () => {
|
||||
const sessionLimitError = Object.assign(new Error('(SSH) Channel open failure: open failed'), {
|
||||
reason: 4
|
||||
})
|
||||
execCommandMock
|
||||
.mockRejectedValueOnce(sessionLimitError)
|
||||
.mockResolvedValueOnce('/bin/bash')
|
||||
.mockResolvedValueOnce('\n')
|
||||
|
||||
await expect(resolveRemoteNodePath(conn)).rejects.toThrow(/Node\.js not found/)
|
||||
})
|
||||
|
||||
it('rethrows SSH session-limit errors from the path probe in strict mode', async () => {
|
||||
const sessionLimitError = Object.assign(new Error('(SSH) Channel open failure: open failed'), {
|
||||
reason: 4
|
||||
})
|
||||
execCommandMock.mockRejectedValueOnce(sessionLimitError)
|
||||
|
||||
await expect(
|
||||
resolveRemoteNodePath(conn, undefined, { rethrowSessionLimitErrors: true })
|
||||
).rejects.toBe(sessionLimitError)
|
||||
})
|
||||
|
||||
it('rethrows SSH session-limit errors from candidate version checks in strict mode', async () => {
|
||||
const sessionLimitError = Object.assign(new Error('(SSH) Channel open failure: open failed'), {
|
||||
reason: 4
|
||||
})
|
||||
execCommandMock
|
||||
.mockResolvedValueOnce('/usr/local/bin/node\n')
|
||||
.mockRejectedValueOnce(sessionLimitError)
|
||||
|
||||
await expect(
|
||||
resolveRemoteNodePath(conn, undefined, { rethrowSessionLimitErrors: true })
|
||||
).rejects.toBe(sessionLimitError)
|
||||
})
|
||||
|
||||
it('rethrows SSH session-limit errors from login-shell resolution in strict mode', async () => {
|
||||
const sessionLimitError = Object.assign(new Error('(SSH) Channel open failure: open failed'), {
|
||||
reason: 4
|
||||
})
|
||||
execCommandMock.mockResolvedValueOnce('\n').mockRejectedValueOnce(sessionLimitError)
|
||||
|
||||
await expect(
|
||||
resolveRemoteNodePath(conn, undefined, { rethrowSessionLimitErrors: true })
|
||||
).rejects.toBe(sessionLimitError)
|
||||
})
|
||||
|
||||
it('rethrows SSH session-limit errors from Windows node resolution in strict mode', async () => {
|
||||
const sessionLimitError = Object.assign(new Error('(SSH) Channel open failure: open failed'), {
|
||||
reason: 4
|
||||
})
|
||||
execCommandMock.mockRejectedValueOnce(sessionLimitError)
|
||||
|
||||
await expect(
|
||||
resolveRemoteNodePath(conn, getRemoteHostPlatform('win32-x64'), {
|
||||
rethrowSessionLimitErrors: true
|
||||
})
|
||||
).rejects.toBe(sessionLimitError)
|
||||
})
|
||||
|
||||
it('throws when every candidate across both strategies is below the minimum', async () => {
|
||||
execCommandMock
|
||||
.mockResolvedValueOnce('/old/node\n') // path probe
|
||||
|
||||
Reference in New Issue
Block a user