mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-24 00:51:31 +01:00
Free test shards stop failing when a test's browser exits during the cleanup check (GST-3447) (#4666)
Free test shards no longer fail with "native process identity unavailable" when a browser a test started exits while the runner is checking it, and the Free Tests planning job gets 10 minutes instead of 5. Why: these were the two causes left of main's flapping Free Tests runs; the other four flaps from 11-18 and 11-19 were fixed earlier by #4490 and #4530. Nothing to do. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
63900b308c
commit
3c9cda0a2d
4 files changed
+36
-9
No files matched your search
@@ -1273,6 +1273,7 @@ const EPILOGUE_WORD: Record<FreeShardStatus, string> = {
|
||||
function trackShardBrowser(stateDir: string, env: NodeJS.ProcessEnv) {
|
||||
class BrowserCleanupError extends Error {}
|
||||
class CaptureStopped extends Error {}
|
||||
class ProcessExited extends Error {}
|
||||
type Identity = { pid: number; parent: number; start: string; daemon: number; root: boolean };
|
||||
type Capture = { abort: AbortController; deadline: number; probes: Set<Promise<unknown>>; records?: [string, string] };
|
||||
const identities = new Map<number, Identity>();
|
||||
@@ -1341,7 +1342,7 @@ function trackShardBrowser(stateDir: string, env: NodeJS.ProcessEnv) {
|
||||
};
|
||||
|
||||
const failure = (error: unknown) => {
|
||||
if (error instanceof CaptureStopped) return;
|
||||
if (error instanceof CaptureStopped || error instanceof ProcessExited) return;
|
||||
const code = (error as NodeJS.ErrnoException)?.code;
|
||||
const file = (error as NodeJS.ErrnoException & { path?: string })?.path;
|
||||
const pid = typeof file === 'string' ? /^\/proc\/(\d+)\//.exec(file)?.[1] : undefined;
|
||||
@@ -1415,10 +1416,11 @@ function trackShardBrowser(stateDir: string, env: NodeJS.ProcessEnv) {
|
||||
const key = `${identity.pid}:${identity.start}`;
|
||||
const recorded = nativeStarts.get(key);
|
||||
if (recorded) return recorded;
|
||||
if (!await live(capture, identity)) throw new BrowserCleanupError('process exited before its native identity was captured');
|
||||
if (!await live(capture, identity)) throw new ProcessExited('process exited before its native identity was captured');
|
||||
const result = await probe(capture, 'ps', ['-p', String(identity.pid), '-o', 'lstart='], 2000);
|
||||
const value = result.status === 0 ? result.stdout.trim().replace(/\s+/g, ' ') : '';
|
||||
if (!value || !await live(capture, identity)) throw new BrowserCleanupError('native process identity unavailable');
|
||||
if (!await live(capture, identity)) throw new ProcessExited('process exited during its native identity probe');
|
||||
if (!value) throw new BrowserCleanupError('native process identity unavailable');
|
||||
check(capture);
|
||||
nativeStarts.set(key, value);
|
||||
return value;
|
||||
@@ -1503,7 +1505,8 @@ function trackShardBrowser(stateDir: string, env: NodeJS.ProcessEnv) {
|
||||
if (state?.chromiumPid !== undefined) validations.push(validateChild(state.chromiumPid, state.chromiumStartTime, state.pid));
|
||||
const results = await Promise.allSettled(validations);
|
||||
check(operation);
|
||||
for (const result of results) if (result.status === 'rejected') throw result.reason;
|
||||
const rejected = results.flatMap(result => result.status === 'rejected' ? [result.reason] : []);
|
||||
if (rejected.length) throw rejected.find(reason => !(reason instanceof ProcessExited)) ?? rejected[0];
|
||||
operation.records = [JSON.stringify(state), JSON.stringify(agent)];
|
||||
} catch (error) {
|
||||
check(operation);
|
||||
|
||||
Reference in new issue
Block a user