feat(launcher): include client logs in diagnostics and format exit codes
Export the active client's wto_ws.log, latest .clog (bounded to 16 MiB), and a client-logs/summary.json metadata snapshot in diagnostics ZIPs without touching player saves. Log build completion, game launch arguments, PID, runtime duration, and hex-annotated Windows NTSTATUS/HRESULT exit codes in the launcher log and status bar. Checked: root typecheck, launcher typecheck, launcher electron-vite build, and exit code formatter runtime check.
This commit is contained in:
1 parent
1c24adbd83
commit
cab73f92f9
5 files changed
+184
-6
No files matched your search
@@ -4,7 +4,7 @@ import { promisify } from 'node:util';
|
||||
import { GAME_FILES } from '@wto/patcher';
|
||||
import { AppError } from '@shared/errors.ts';
|
||||
import offlineGameArguments from '@shared/offline-game-arguments.json';
|
||||
import type { GameExit } from '@shared/schemas/launch.ts';
|
||||
import { formatExitCode, type GameExit } from '@shared/schemas/launch.ts';
|
||||
|
||||
const execute = promisify(execFile);
|
||||
|
||||
@@ -19,7 +19,11 @@ export async function runGameProcess(
|
||||
): Promise<GameExit> {
|
||||
if (await gameProcessRunning(signal)) throw new AppError('launch_game_running');
|
||||
signal.throwIfAborted();
|
||||
const child = spawn(join(copyPath, GAME_FILES.executable), [...offlineGameArguments, ...additionalArguments], {
|
||||
const executable = join(copyPath, GAME_FILES.executable);
|
||||
const args = [...offlineGameArguments, ...additionalArguments];
|
||||
const startedAt = Date.now();
|
||||
console.info('[game] starting:', executable, args);
|
||||
const child = spawn(executable, args, {
|
||||
cwd: copyPath, shell: false, stdio: 'ignore',
|
||||
});
|
||||
const stop = (): void => { child.kill(); };
|
||||
@@ -27,6 +31,7 @@ export async function runGameProcess(
|
||||
try {
|
||||
return await new Promise<GameExit>((resolve, reject) => {
|
||||
child.once('spawn', () => {
|
||||
console.info('[game] process started, pid:', child.pid ?? 'unknown');
|
||||
if (signal.aborted) stop();
|
||||
else onStart();
|
||||
});
|
||||
@@ -36,8 +41,12 @@ export async function runGameProcess(
|
||||
});
|
||||
child.once('close', (code, reason) => {
|
||||
const logFolder = join(copyPath, '.game_logs');
|
||||
const elapsedMs = Date.now() - startedAt;
|
||||
const summary = code !== null ? formatExitCode(code) : (reason ?? 'unknown');
|
||||
if (code !== 0 && !signal.aborted) {
|
||||
console.warn('[game] process exited:', code ?? reason, logFolder);
|
||||
console.warn('[game] process exited:', summary, `after ${elapsedMs} ms`, logFolder);
|
||||
} else {
|
||||
console.info('[game] process exited:', summary, `after ${elapsedMs} ms`);
|
||||
}
|
||||
resolve({ code, signal: reason, logFolder });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user