File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,25 @@ export function universalApiPlugin(opts?: UniversalApiOptions): Plugin {
3131
3232 logger . info ( `plugin ${ options . disable ? "disabled" : "started" } ` ) ;
3333 logger . debug ( "Vite configResolved: FINISH" ) ;
34+ /* v8 ignore start */
35+ /**
36+ * INFO
37+ * plugin print on process.stoud/sterr with console. If the process running in background,
38+ * when client disconnect session, stdout/stderr receive EIO/EPIPE error.
39+ * So register an hanlder to avoid process's death for uncaughtException
40+ */
41+ const suppressIoError = ( err : NodeJS . ErrnoException ) => {
42+ if ( err . code !== 'EIO' && err . code !== 'EPIPE' ) {
43+ throw err ;
44+ }
45+ } ;
46+ if ( process . stdout . listenerCount ( 'error' ) === 0 ) {
47+ process . stdout . on ( 'error' , suppressIoError ) ;
48+ }
49+ if ( process . stderr . listenerCount ( 'error' ) === 0 ) {
50+ process . stderr . on ( 'error' , suppressIoError ) ;
51+ }
52+ /* v8 ignore stop */
3453 } ,
3554 configureServer ( server ) {
3655 if ( options . disable ) {
You can’t perform that action at this time.
0 commit comments