Skip to content

Commit bc98dd1

Browse files
goosewobblerclaude
andcommitted
fix: set DISPLAY in worker process and configure tauri-driver connection
The DISPLAY environment variable was not available in the WDIO worker process, causing ChromeDriver and diagnostic commands to fail when trying to launch the Tauri binary with GTK. This fix: 1. Sets DISPLAY in the worker process environment (onWorkerStart) so that ChromeDriver and all child processes have access to the X server 2. Configures WDIO to connect to tauri-driver's WebDriver endpoint instead of spawning a separate ChromeDriver instance 3. Keeps DISPLAY set when spawning tauri-driver for redundancy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e3bb206 commit bc98dd1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

packages/tauri-service/src/launcher.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ export default class TauriLaunchService {
2828
* Prepare the Tauri service
2929
*/
3030
async onPrepare(
31-
_config: Options.Testrunner,
31+
config: Options.Testrunner,
3232
capabilities: TauriCapabilities[] | Record<string, { capabilities: TauriCapabilities }>,
3333
): Promise<void> {
3434
log.debug('Preparing Tauri service...');
3535

36+
// Configure WDIO to connect to tauri-driver instead of spawning ChromeDriver
37+
const tauriDriverPort = this.options.tauriDriverPort || 4444;
38+
config.hostname = config.hostname || 'localhost';
39+
config.port = config.port || tauriDriverPort;
40+
log.info(`Configuring WDIO to connect to tauri-driver at ${config.hostname}:${config.port}`);
41+
3642
// Check for unsupported platforms
3743
if (process.platform === 'darwin') {
3844
const errorMessage =
@@ -132,6 +138,13 @@ export default class TauriLaunchService {
132138
async onWorkerStart(cid: string, caps: TauriCapabilities): Promise<void> {
133139
log.debug(`Starting Tauri worker session: ${cid}`);
134140

141+
// On Linux, ensure DISPLAY is set in the worker process environment
142+
// This is needed for ChromeDriver and any diagnostic commands
143+
if (process.platform === 'linux' && !process.env.DISPLAY) {
144+
process.env.DISPLAY = ':99';
145+
log.info(`Set DISPLAY=${process.env.DISPLAY} in worker process for ChromeDriver and diagnostics`);
146+
}
147+
135148
// App binary path is already resolved in onPrepare
136149
const appPath = caps['tauri:options']?.application;
137150
if (!appPath) {
@@ -330,9 +343,17 @@ export default class TauriLaunchService {
330343
}
331344

332345
return new Promise((resolve, reject) => {
346+
// On Linux, explicitly set DISPLAY for xvfb compatibility
347+
const env = { ...process.env };
348+
if (process.platform === 'linux') {
349+
env.DISPLAY = env.DISPLAY || ':99';
350+
log.info(`Setting DISPLAY=${env.DISPLAY} for tauri-driver and children`);
351+
}
352+
333353
this.tauriDriverProcess = spawn(tauriDriverPath, args, {
334354
stdio: ['ignore', 'pipe', 'pipe'],
335355
detached: false,
356+
env,
336357
});
337358

338359
this.tauriDriverProcess.stdout?.on('data', (data: Buffer) => {

0 commit comments

Comments
 (0)