11import * as path from 'path' ;
22import * as os from 'node:os' ;
33import * as crypto from 'node:crypto' ;
4+ import * as fs from 'node:fs' ;
45
56import pWaitFor from 'p-wait-for' ;
67import { execa } from 'execa' ;
@@ -17,7 +18,7 @@ import { IpcClient } from '@roo-code-cloud/ipc';
1718import type { JobPayload , JobType } from '@roo-code-cloud/db' ;
1819
1920import { Logger } from './logger' ;
20- import { isDockerContainer } from './utils' ;
21+ import { isFlyMachine , isDockerContainer } from './utils' ;
2122import { SlackNotifier } from './slack' ;
2223
2324const TIMEOUT = 30 * 60 * 1_000 ;
@@ -71,26 +72,36 @@ export const runTask = async <T extends JobType>({
7172 `${ crypto . randomUUID ( ) . slice ( 0 , 8 ) } .sock` ,
7273 ) ;
7374
74- const env = { ROO_CODE_IPC_SOCKET_PATH : ipcSocketPath } ;
7575 const controller = new AbortController ( ) ;
7676 const cancelSignal = controller . signal ;
77- const containerized = isDockerContainer ( ) ;
77+ const containerized = isFlyMachine ( ) || isDockerContainer ( ) ;
7878
7979 const codeCommand = containerized
80- ? `xvfb-run --auto-servernum --server-num=1 code --wait --log trace --disable-workspace-trust --disable-gpu --disable-lcd-text --no-sandbox --user-data-dir /roo/.vscode --password-store="basic" -n ${ workspacePath } `
81- : `code --disable-workspace-trust -n ${ workspacePath } ` ;
80+ ? `ROO_CODE_IPC_SOCKET_PATH= ${ ipcSocketPath } xvfb-run --auto-servernum --server-num=1 code --wait --log trace --disable-workspace-trust --disable-gpu --disable-lcd-text --no-sandbox --user-data-dir /roo/.vscode --password-store="basic" -n ${ workspacePath } `
81+ : `ROO_CODE_IPC_SOCKET_PATH= ${ ipcSocketPath } code --disable-workspace-trust -n ${ workspacePath } ` ;
8282
8383 logger . info ( codeCommand ) ;
8484
8585 const subprocess = execa ( {
86- env,
8786 shell : '/bin/bash' ,
8887 cancelSignal,
8988 } ) `${ codeCommand } ` ;
9089
9190 // If debugging, add `--verbose` to `command` and uncomment the following line.
9291 // subprocess.stdout.pipe(process.stdout)
9392
93+ try {
94+ await pWaitFor ( ( ) => fs . existsSync ( ipcSocketPath ) , {
95+ interval : 250 ,
96+ timeout : 10_000 ,
97+ } ) ;
98+ } catch ( _error ) {
99+ logger . error ( `IPC socket was not created within timeout: ${ ipcSocketPath } ` ) ;
100+ throw new Error (
101+ `IPC socket was not created within timeout -> ${ ipcSocketPath } ` ,
102+ ) ;
103+ }
104+
94105 let client : IpcClient | undefined = undefined ;
95106 let attempts = 5 ;
96107
0 commit comments