Skip to content

Commit ad0b591

Browse files
committed
fix: steel browser errors
1 parent 53148c7 commit ad0b591

File tree

3 files changed

+45
-22
lines changed

3 files changed

+45
-22
lines changed

source/commands/browser/start.tsx

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ type Props = {
4141
options: zod.infer<typeof options>;
4242
};
4343

44-
function isDockerRunning() {
45-
try {
46-
spawn('docker', ['info']);
47-
return true;
48-
} catch {
49-
return false;
50-
}
44+
function isDockerRunning(): Promise<boolean> {
45+
return new Promise(resolve => {
46+
const isRunning = spawn('docker', ['info']);
47+
isRunning.on('close', code => {
48+
resolve(code === 0);
49+
});
50+
isRunning.on('error', () => {
51+
resolve(false);
52+
});
53+
});
5154
}
5255

5356
export default function Start({options}: Props) {
@@ -64,7 +67,8 @@ export default function Start({options}: Props) {
6467
cwd: CONFIG_DIR,
6568
});
6669

67-
if (options?.docker_check && !isDockerRunning()) {
70+
const dockerRunning = await isDockerRunning();
71+
if (!dockerRunning) {
6872
setDockerError(true);
6973
setLoading(false);
7074
return;
@@ -75,18 +79,29 @@ export default function Start({options}: Props) {
7579

7680
const folderName = path.basename(REPO_URL, '.git');
7781

78-
spawn('docker-compose', ['-f', 'docker-compose.dev.yml', 'up', '-d'], {
79-
cwd: path.join(CONFIG_DIR, folderName),
80-
stdio: 'inherit',
81-
env: {
82-
...process.env,
83-
API_PORT: String(options?.port || 3000),
84-
ENABLE_VERBOSE_LOGGING: options?.verbose || 'false',
82+
const dockerCompose = spawn(
83+
'docker-compose',
84+
['-f', 'docker-compose.dev.yml', 'up', '-d'],
85+
{
86+
cwd: path.join(CONFIG_DIR, folderName),
87+
stdio: 'inherit',
88+
env: {
89+
...process.env,
90+
API_PORT: String(options?.port || 3000),
91+
ENABLE_VERBOSE_LOGGING: options?.verbose || 'false',
92+
},
8593
},
86-
});
94+
);
8795

88-
setStatus('Opening browser...');
89-
await open('http://localhost:5173');
96+
dockerCompose.on('close', async code => {
97+
if (code !== 0) {
98+
setDockerError(true);
99+
setLoading(false);
100+
return;
101+
}
102+
setStatus('Opening browser...');
103+
await open('http://localhost:5173');
104+
});
90105
}
91106
start();
92107
}, []);
@@ -109,9 +124,19 @@ export default function Start({options}: Props) {
109124
);
110125
}
111126

127+
if (status === 'Opening browser...') {
128+
return (
129+
<Callout variant="success" title="Development Environment Started">
130+
Browser opened at http://localhost:5173
131+
</Callout>
132+
);
133+
}
134+
112135
return (
113-
<Callout variant="success" title="Development Environment Started">
114-
Browser opened at http://localhost:5173
136+
<Callout variant="info" title="Starting Development Environment">
137+
<Text>
138+
<Spinner type="dots" /> {status}
139+
</Text>
115140
</Callout>
116141
);
117142
}

source/hooks/useapi.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export function useApi({
5050
setError(new Error(json.message));
5151
}
5252
} catch (err) {
53-
console.error('API Error:', error);
5453
setError(err as Error);
5554
}
5655
setLoading(false);

source/hooks/uselazyapi.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export function useLazyApi({
7676
setError(new Error(json.message));
7777
}
7878
} catch (err) {
79-
console.error('API Error:', err);
8079
setError(err as Error);
8180
}
8281

0 commit comments

Comments
 (0)