Skip to content

Commit 33c0699

Browse files
committed
refactor(e2e): remove debug instrumentation from serve()
1 parent 0c9111d commit 33c0699

1 file changed

Lines changed: 2 additions & 41 deletions

File tree

integration/models/application.ts

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { execSync } from 'node:child_process';
21
import * as path from 'node:path';
32

43
import { parsePublishableKey } from '@clerk/shared/keys';
@@ -162,7 +161,6 @@ export const application = (
162161
return { port, serverUrl: runtimeServerUrl };
163162
}
164163

165-
log(`Running serve command: "${scripts.serve}" with PORT=${port}, detached=${opts.detached}`);
166164
const proc = run(scripts.serve, {
167165
cwd: appDirPath,
168166
env: { PORT: port.toString() },
@@ -176,47 +174,10 @@ export const application = (
176174
log(msg);
177175
},
178176
});
179-
log(`Serve process spawned: pid=${proc.pid}`);
180177

181178
if (opts.detached) {
182-
// Give the process a moment to start, then check its state
183-
await new Promise(res => setTimeout(res, 10000));
184-
try {
185-
const procAlive = execSync(`kill -0 ${proc.pid} 2>&1 && echo "alive" || echo "dead"`, {
186-
encoding: 'utf-8',
187-
}).trim();
188-
log(`Serve process ${proc.pid} status after 10s: ${procAlive}`);
189-
// Check port binding
190-
const portCheck = execSync(`lsof -i :${port} -P -n 2>&1 || echo "(lsof: no results)"`, { encoding: 'utf-8' });
191-
log(`Port ${port} check:\n${portCheck}`);
192-
// Check process tree
193-
const pstree = execSync(`pstree -p ${proc.pid} 2>&1 || echo "(pstree failed)"`, { encoding: 'utf-8' });
194-
log(`Process tree:\n${pstree}`);
195-
} catch (debugErr) {
196-
log(`Debug check error: ${debugErr}`);
197-
}
198-
199-
const shouldExit = () => {
200-
if (proc.exitCode != null) {
201-
log(`Serve process has exitCode=${proc.exitCode}`);
202-
return true;
203-
}
204-
return false;
205-
};
206-
try {
207-
await waitForServer(runtimeServerUrl, { log, maxAttempts: 120, shouldExit });
208-
} catch (e) {
209-
try {
210-
const stdoutContent = await fs.readFile(stdoutFilePath, 'utf-8');
211-
const stderrContent = await fs.readFile(stderrFilePath, 'utf-8');
212-
log(`Serve stdout:\n${stdoutContent || '(empty)'}`);
213-
log(`Serve stderr:\n${stderrContent || '(empty)'}`);
214-
} catch {
215-
log('Could not read serve log files');
216-
}
217-
log(`Serve process exitCode=${proc.exitCode}, killed=${proc.killed}, pid=${proc.pid}`);
218-
throw e;
219-
}
179+
const shouldExit = () => !!proc.exitCode && proc.exitCode !== 0;
180+
await waitForServer(runtimeServerUrl, { log, maxAttempts: Infinity, shouldExit });
220181
} else {
221182
await waitForIdleProcess(proc);
222183
}

0 commit comments

Comments
 (0)