From 3fbe26ddf7adb568861621d62078455ba487cc99 Mon Sep 17 00:00:00 2001 From: NimBold Date: Thu, 27 Aug 2026 19:29:51 +0330 Subject: [PATCH] test(startup): collect Windows crash diagnostics (#37) - Issue #37: include packaged stdout, stderr, and matching Windows Application events when the stability smoke fails.\n- Keep the diagnostic scoped to the smoke harness so no product behavior changes.\n\nRefs #37. --- scripts/smoke-packaged-app.js | 46 ++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/scripts/smoke-packaged-app.js b/scripts/smoke-packaged-app.js index 3d48b3f..b6cb9cd 100755 --- a/scripts/smoke-packaged-app.js +++ b/scripts/smoke-packaged-app.js @@ -37,6 +37,7 @@ const child = spawn(executable, [], { }); let stderr = ''; +let stdout = ''; let spawnError = null; let readyPort = null; let childExit = null; @@ -55,7 +56,9 @@ child.on('exit', (code, signal) => { child.stderr.on('data', data => { stderr += data.toString(); }); -child.stdout.on('data', () => {}); +child.stdout.on('data', data => { + stdout += data.toString(); +}); function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); @@ -187,6 +190,45 @@ if ($visible.Count -gt 0) { } } +function windowsCrashDiagnostics() { + if (process.platform !== 'win32') { + return ''; + } + + const script = ` +$start = (Get-Date).AddMinutes(-15) +$events = @(Get-WinEvent -FilterHashtable @{ LogName = 'Application'; StartTime = $start } -ErrorAction SilentlyContinue | + Where-Object { + $_.ProviderName -in @('Application Error', 'Windows Error Reporting') -and + $_.Message -match '(?i)firelink' + } | + Select-Object -First 8) +foreach ($event in $events) { + Write-Output ("EVENT " + $event.TimeCreated.ToString('o') + " " + $event.ProviderName + " ID=" + $event.Id) + Write-Output $event.Message +} +`; + + try { + return execFileSync('powershell', ['-NoProfile', '-NonInteractive', '-Command', script], { + encoding: 'utf8', + stdio: ['ignore', 'pipe', 'pipe'], + windowsHide: true, + }).trim(); + } catch { + return ''; + } +} + +function startupDiagnostics() { + const sections = []; + if (stdout.trim()) sections.push(`Firelink stdout:\n${stdout.slice(-6000)}`); + if (stderr.trim()) sections.push(`Firelink stderr:\n${stderr.slice(-6000)}`); + const crashEvents = windowsCrashDiagnostics(); + if (crashEvents) sections.push(`Windows application events:\n${crashEvents.slice(-12000)}`); + return sections.join('\n\n'); +} + function waitForChildExit(timeoutMs) { if (childExit) { return Promise.resolve(true); @@ -396,6 +438,8 @@ try { console.log(`Packaged Firelink smoke passed on 127.0.0.1:${readyPort} with ${stabilityMs}ms stability`); } catch (error) { console.error(error instanceof Error ? error.message : String(error)); + const diagnostics = startupDiagnostics(); + if (diagnostics) console.error(`\nStartup diagnostics:\n${diagnostics}`); process.exitCode = 1; } finally { if (!await terminateChild()) {