@@ -629,6 +629,18 @@ function nodeLoader() {
629629 isInspectEnabled
630630 } ;
631631 window . isNodeReady = false ;
632+ let nodeErrorLogCount = 0 ;
633+ // 10 node error logs are allowed on console every 2 seconds to prevent freeze due to
634+ const MAX_NODE_ERROR_LOGS_ALLOWED = 10 ;
635+ const NODE_ERROR_LOGS_RESET_INTERVAL = 2000 ;
636+ setInterval ( ( ) => {
637+ // allow only logging up to x log lines in a given interval.
638+ if ( ! window . debugMode && nodeErrorLogCount > MAX_NODE_ERROR_LOGS_ALLOWED ) {
639+ console . error ( "Too many node Errors, some errors were omitted from console." ,
640+ "Please enable `Debug menu> Phoenix code diagnostic tools> enable detailed logs` to view all." ) ;
641+ }
642+ nodeErrorLogCount = 0 ;
643+ } , NODE_ERROR_LOGS_RESET_INTERVAL ) ;
632644
633645 window . __TAURI__ . path . resolveResource ( "src-node/index.js" )
634646 . then ( async nodeSrcPath => {
@@ -679,7 +691,16 @@ function nodeLoader() {
679691 }
680692 }
681693 } ) ;
682- command . stderr . on ( 'data' , line => console . error ( `PhNode: ${ line } ` ) ) ;
694+ command . stderr . on ( 'data' , line => {
695+ if ( window . debugMode || nodeErrorLogCount < MAX_NODE_ERROR_LOGS_ALLOWED ) {
696+ // in release builds, too many node errors from file system/other sources can
697+ // happen, Eg. user opens a very large project and fs watchers goes bust.
698+ // if that happens, the app may get stuck logging large number of errors to console, so
699+ // we show atmost 10 error lines every 10 seconds in non-debug builds.
700+ console . error ( `PhNode: ${ line } ` ) ;
701+ }
702+ nodeErrorLogCount ++ ;
703+ } ) ;
683704 child = await command . spawn ( ) ;
684705
685706 const execNode = function ( commandCode , commandData ) {
0 commit comments