@@ -45,23 +45,30 @@ export const shape = () =>
4545export const loadScore = () => import('@objectstack/scenarios/score');
4646` ;
4747
48- // Preloaded into the child: every URL Node resolves, printed as the last line.
48+ // Preloaded into the child: every URL Node resolves, written to the file
49+ // named by SCENARIOS_RESOLVE_RECORD. A FILE, written synchronously: the record
50+ // is ~140 KB, larger than a pipe's buffer, and a stdout write from an `exit`
51+ // handler is not flushed past what the pipe takes before the process ends
52+ // (a truncated record on a loaded CI runner).
4953const RECORDER = `
54+ const { writeFileSync } = require('node:fs');
5055const { registerHooks } = require('node:module');
5156const seen = [];
5257registerHooks({ resolve(specifier, context, next) { const r = next(specifier, context); seen.push(r.url); return r; } });
53- process.on('exit', () => process.stdout.write('\\n' + JSON.stringify(seen) + '\\n' ));
58+ process.on('exit', () => writeFileSync( process.env.SCENARIOS_RESOLVE_RECORD, JSON.stringify(seen)));
5459` ;
5560
5661let fixture = '' ;
5762
5863function runNode ( code : string , kind : 'module' | 'commonjs' ) : { out : Record < string , unknown > ; resolved : string [ ] } {
64+ const record = join ( fixture , `resolved-${ kind } .json` ) ;
65+ rmSync ( record , { force : true } ) ;
5966 const stdout = execFileSync ( process . execPath , [ '--require' , join ( fixture , 'recorder.cjs' ) , `--input-type=${ kind } ` , '-e' , code ] , {
6067 cwd : fixture ,
6168 encoding : 'utf8' ,
69+ env : { ...process . env , SCENARIOS_RESOLVE_RECORD : record } ,
6270 } ) ;
63- const lines = stdout . trim ( ) . split ( '\n' ) ;
64- return { out : JSON . parse ( lines [ 0 ] ! ) as Record < string , unknown > , resolved : JSON . parse ( lines [ lines . length - 1 ] ! ) as string [ ] } ;
71+ return { out : JSON . parse ( stdout . trim ( ) ) as Record < string , unknown > , resolved : JSON . parse ( readFileSync ( record , 'utf8' ) ) as string [ ] } ;
6572}
6673
6774const probe = ( mod : string ) => `
0 commit comments