@@ -57,12 +57,72 @@ process.on('unhandledRejection', (err) => {
5757 return ; // Don't crash for peer lookup failures
5858 }
5959
60+ // Handle ECONNRESET errors gracefully - these are common network issues
61+ if ( err && ( err . code === 'ECONNRESET' || err . errno === - 104 ) ) {
62+ console . warn ( `Network connection reset (ECONNRESET): ${ err . message } ` ) ;
63+ return ; // Don't crash for connection reset errors
64+ }
65+
66+ // Handle ERR_UNSUPPORTED_PROTOCOL errors gracefully
67+ if ( err && err . code === 'ERR_UNSUPPORTED_PROTOCOL' ) {
68+ console . warn ( `Unsupported protocol error (ERR_UNSUPPORTED_PROTOCOL): ${ err . message } ` ) ;
69+ return ; // Don't crash for protocol errors
70+ }
71+
72+ // Handle EPIPE (broken pipe) errors gracefully
73+ if ( err && ( err . code === 'EPIPE' || err . errno === - 32 ) ) {
74+ console . warn ( `Broken pipe error (EPIPE): ${ err . message } ` ) ;
75+ return ; // Don't crash for broken pipe errors
76+ }
77+
78+ // Handle ETIMEDOUT errors gracefully - these are common database connection timeouts
79+ if ( err && ( err . code === 'ETIMEDOUT' || err . errno === - 110 ) ) {
80+ console . warn ( `Connection timeout error (ETIMEDOUT): ${ err . message } ` ) ;
81+ return ; // Don't crash for timeout errors
82+ }
83+
84+ // Handle Sequelize "Got timeout reading communication packets" errors gracefully
85+ if ( err && err . message && err . message . includes ( 'Got timeout reading communication packets' ) ) {
86+ console . warn ( `Sequelize communication timeout error: ${ err . message } ` ) ;
87+ return ; // Don't crash for database communication timeout errors
88+ }
89+
6090 // For all other unhandled rejections, crash the node
6191 console . error ( 'Something went really wrong! OT-node shutting down...' , err ) ;
6292 process . exit ( 1 ) ;
6393} ) ;
6494
6595process . on ( 'uncaughtException' , ( err ) => {
96+ // Handle ERR_UNSUPPORTED_PROTOCOL errors gracefully
97+ if ( err && err . code === 'ERR_UNSUPPORTED_PROTOCOL' ) {
98+ console . warn ( `Unsupported protocol error (ERR_UNSUPPORTED_PROTOCOL): ${ err . message } ` ) ;
99+ return ; // Don't crash for protocol errors
100+ }
101+
102+ // Handle EPIPE (broken pipe) errors gracefully
103+ if ( err && ( err . code === 'EPIPE' || err . errno === - 32 ) ) {
104+ console . warn ( `Broken pipe error (EPIPE): ${ err . message } ` ) ;
105+ return ; // Don't crash for broken pipe errors
106+ }
107+
108+ // Handle ECONNRESET errors gracefully
109+ if ( err && ( err . code === 'ECONNRESET' || err . errno === - 104 ) ) {
110+ console . warn ( `Network connection reset (ECONNRESET): ${ err . message } ` ) ;
111+ return ; // Don't crash for connection reset errors
112+ }
113+
114+ // Handle ETIMEDOUT errors gracefully - these are common database connection timeouts
115+ if ( err && ( err . code === 'ETIMEDOUT' || err . errno === - 110 ) ) {
116+ console . warn ( `Connection timeout error (ETIMEDOUT): ${ err . message } ` ) ;
117+ return ; // Don't crash for timeout errors
118+ }
119+
120+ // Handle Sequelize "Got timeout reading communication packets" errors gracefully
121+ if ( err && err . message && err . message . includes ( 'Got timeout reading communication packets' ) ) {
122+ console . warn ( `Sequelize communication timeout error: ${ err . message } ` ) ;
123+ return ; // Don't crash for database communication timeout errors
124+ }
125+
66126 console . error ( 'Something went really wrong! OT-node shutting down...' , err ) ;
67127 process . exit ( 1 ) ;
68128} ) ;
0 commit comments