File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
4+ const { spawnSync } = require ( 'child_process' ) ;
5+
6+ // This test verifies that setupHistory callback errors propagate.
7+ // On main branch (without your fix), this test MUST FAIL.
8+ // After your patch, it MUST PASS.
9+
10+ const child = spawnSync ( process . execPath , [ '-e' , `
11+ const repl = require('repl');
12+ const server = repl.start({ prompt: "" });
13+ server.setupHistory('/tmp/history-test', (err) => {
14+ throw new Error("INTENTIONAL_CALLBACK_THROW");
15+ });
16+ ` ] , {
17+ encoding : 'utf8'
18+ } ) ;
19+
20+ // The bug: before your fix, Node *does NOT* propagate the thrown error,
21+ // so stderr does NOT contain the message.
22+ // After your fix, stderr WILL contain INTENTIONAL_CALLBACK_THROW.
23+
24+ assert . match ( child . stderr , / I N T E N T I O N A L _ C A L L B A C K _ T H R O W / ,
25+ 'setupHistory callback error did NOT propagate' ) ;
26+
You can’t perform that action at this time.
0 commit comments