mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-23 00:05:27 +00:00
Merge isolated bootstrap transport regressions into UI review
This commit is contained in:
2 files changed
+60
-6
No files matched your search
@@ -32,7 +32,7 @@ function writeFile(root, relativePath, content) {
|
||||
}
|
||||
|
||||
function run(args = [], options = {}) {
|
||||
return spawnSync(process.execPath, [SCRIPT, ...args], {
|
||||
return spawnSync(process.execPath, [...(options.nodeArgs || []), SCRIPT, ...args], {
|
||||
input: options.input || '',
|
||||
encoding: 'utf8',
|
||||
env: {
|
||||
@@ -46,6 +46,18 @@ function run(args = [], options = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
function isolatedBootstrapEnv(root) {
|
||||
return {
|
||||
HOME: root, USERPROFILE: root, ECC_AGENT_DATA_HOME: path.join(root, 'agent-data'),
|
||||
QODER_PLUGIN_ROOT: '', ECC_HOOK_DEADLINE_MS: '', NODE_OPTIONS: '',
|
||||
};
|
||||
}
|
||||
|
||||
function spawnDiagnostic(result) {
|
||||
return JSON.stringify({ status: result.status, signal: result.signal,
|
||||
error: result.error?.code || null, stderr: result.stderr });
|
||||
}
|
||||
|
||||
function test(name, fn) {
|
||||
try {
|
||||
fn();
|
||||
@@ -342,13 +354,36 @@ process.exit(7);
|
||||
const root = createTempDir();
|
||||
try {
|
||||
const result = run(['node', path.join('scripts', 'missing.js')], {
|
||||
root,
|
||||
input: 'raw-input',
|
||||
root, cwd: root,
|
||||
// No stdin is needed to observe MODULE_NOT_FOUND. Sending input can
|
||||
// race the child's early exit and legitimately produce EPIPE instead.
|
||||
input: '',
|
||||
env: isolatedBootstrapEnv(root),
|
||||
});
|
||||
const diagnostic = spawnDiagnostic(result);
|
||||
assert.strictEqual(result.error, undefined, diagnostic);
|
||||
assert.strictEqual(result.status, 1, diagnostic);
|
||||
assert.strictEqual(result.stdout, '', diagnostic);
|
||||
assert.ok(result.stderr.includes('Cannot find module'), diagnostic);
|
||||
} finally {
|
||||
cleanup(root);
|
||||
}
|
||||
})) passed++; else failed++;
|
||||
|
||||
assert.strictEqual(result.status, 1);
|
||||
assert.strictEqual(result.stdout, '');
|
||||
assert.ok(result.stderr.includes('Cannot find module'));
|
||||
if (test('a child that exits 1 with an input EPIPE retains fail-open execution diagnostics', () => {
|
||||
const root = createTempDir();
|
||||
try {
|
||||
const result = run(['node', path.join('scripts', 'missing.js')], {
|
||||
root, cwd: root, input: 'raw-input', env: isolatedBootstrapEnv(root),
|
||||
nodeArgs: ['--require', path.join(__dirname, '../lib/helpers/plugin-bootstrap-epipe.js')],
|
||||
});
|
||||
const diagnostic = spawnDiagnostic(result);
|
||||
assert.strictEqual(result.error, undefined, diagnostic);
|
||||
assert.strictEqual(result.status, 0, diagnostic);
|
||||
assert.strictEqual(result.stdout, '', diagnostic);
|
||||
assert.ok(result.stderr.includes('[TestSpawn] child exited 1 with EPIPE'), diagnostic);
|
||||
assert.ok(result.stderr.includes('Cannot find module'), diagnostic);
|
||||
assert.ok(result.stderr.includes('bootstrap execution failed: spawnSync node EPIPE'), diagnostic);
|
||||
} finally {
|
||||
cleanup(root);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
// Isolate the child-result contract from an OS scheduling race: a missing
|
||||
// target can exit 1 while closing stdin before the bootstrap finishes writing.
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const target = path.resolve(process.env.CLAUDE_PLUGIN_ROOT, 'scripts', 'missing.js');
|
||||
|
||||
childProcess.spawnSync = (command, args) => {
|
||||
assert.strictEqual(command, process.execPath);
|
||||
assert.deepStrictEqual(args, [target]);
|
||||
process.stderr.write('[TestSpawn] child exited 1 with EPIPE\n');
|
||||
return {
|
||||
status: 1, signal: null, stdout: Buffer.alloc(0),
|
||||
stderr: Buffer.from("Error: Cannot find module 'missing fixture'\n"),
|
||||
error: Object.assign(new Error('spawnSync node EPIPE'), { code: 'EPIPE' }),
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user