Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
fix(diag): expose redacted server child stderr in opted-in Windows VM testing
davoodmehraban89 committed
Oct 16, 2026 at 23:55 UTC
c722d42c350325e022c3e0b875452c7ac8368945
1 file changed
+15
-1
electron/main.cjs
+15
-1
@@ -65,10 +65,12 @@ function serverPath() {
65
66
async function startServer() {
67
const script = serverPath();
68
+ // Expose bounded diagnostic stderr only in a synthetic-data Windows VM.
69
+ const vmDiagnostics = process.env.TREASURYFLOW_VM_DIAGNOSTICS === '1';
70
serverProcess = spawn(process.execPath, [script], {
71
cwd: path.dirname(script),
72
windowsHide: true,
71
- stdio: 'ignore',
73
+ stdio: vmDiagnostics ? ['ignore', 'ignore', 'pipe'] : 'ignore',
74
env: {
75
...process.env,
76
ELECTRON_RUN_AS_NODE: '1',
@@ -79,8 +81,20 @@ async function startServer() {
81
BANK_ADAPTER_MODE: 'disabled'
82
}
83
});
84
+ let childStderr = '';
85
+ if (vmDiagnostics && serverProcess.stderr) {
86
+ serverProcess.stderr.on('data', chunk => {
87
+ childStderr = (childStderr + chunk.toString('utf8')).slice(-2400);
88
+ });
89
+ }
90
serverProcess.on('error', err => { serverStartError = err; });
91
serverProcess.on('exit', code => {
92
+ if (vmDiagnostics && childStderr) {
93
+ const scrubbed = childStderr
94
+ .replace(/\b(password|token|secret|credential|authorization|api[_-]?key)\s*[:=]\s*\S+/gi, '$1=[REDACTED]')
95
+ .replace(/https?:\/\/[^@\s]+@/gi, 'https://[REDACTED]@');
96
+ console.error('TreasuryFlow child stderr (sanitized):', scrubbed);
97
+ }
98
if (!app.isQuitting && code !== 0) console.error('TreasuryFlow server exited', code);
99
});
100
await waitForServer(`http://127.0.0.1:${PORT}/api/ready`);