@@ -28,9 +28,30 @@ let backendProcess = null;
2828// Common log window instance for all backend processes
2929let storedLogWindow = null ;
3030
31- // Store error messages (keep last 10 lines to avoid memory issues)
31+ // Store error messages accumulated from the current process run
3232let lastBackendError = null ;
3333
34+ const ERROR_HINTS = [
35+ {
36+ pattern : / b i n d : T h e r e q u e s t e d a d d r e s s i s n o t v a l i d / ,
37+ message : "Network address unavailable" ,
38+ advice :
39+ "The configured IP address doesn't exist on this machine. Check your network adapter or ADJ." ,
40+ } ,
41+ {
42+ pattern : / f a i l e d t o s t a r t U D P s e r v e r / ,
43+ message : "UDP server failed to start" ,
44+ advice : "Another process may already be using this port." ,
45+ } ,
46+ ] ;
47+
48+ function getHint ( errorText ) {
49+ const match = ERROR_HINTS . find ( ( { pattern } ) => pattern . test ( errorText ) ) ;
50+ return match
51+ ? `${ match . message } \n\n${ match . advice } \n\n${ errorText } `
52+ : errorText ;
53+ }
54+
3455/**
3556 * Starts the backend process by spawning the backend binary with the user configuration.
3657 * @returns {void }
@@ -73,6 +94,9 @@ async function startBackend(logWindow = null) {
7394 cwd : workingDir ,
7495 } ) ;
7596
97+ console . log ( "[DEBUG] backendProcess.stderr:" , backendProcess . stderr ) ;
98+ console . log ( "[DEBUG] backendProcess.stdout:" , backendProcess . stdout ) ;
99+
76100 // Log stdout output from backend
77101 backendProcess . stdout . on ( "data" , ( data ) => {
78102 const text = data . toString ( ) . trim ( ) ;
@@ -101,6 +125,7 @@ async function startBackend(logWindow = null) {
101125 backendProcess . stderr . on ( "data" , ( data ) => {
102126 const errorMsg = data . toString ( ) . trim ( ) ;
103127 logger . backend . error ( errorMsg ) ;
128+ console . log ( "[DEBUG stderr chunk]" , JSON . stringify ( errorMsg ) ) ;
104129 lastBackendError = errorMsg ;
105130
106131 // Send error message to log window
@@ -129,7 +154,8 @@ async function startBackend(logWindow = null) {
129154 let errorMessage = `Backend exited with code ${ code } ` ;
130155
131156 if ( lastBackendError ) {
132- errorMessage += `\n\n${ lastBackendError } ` ;
157+ const stripped = lastBackendError . replace ( / \x1b \[ [ 0 - 9 ; ] * m / g, "" ) ;
158+ errorMessage += `\n\n${ getHint ( stripped ) } ` ;
133159 } else {
134160 errorMessage += "\n\n(No error output captured)" ;
135161 }
0 commit comments