@@ -641,22 +641,7 @@ class DirectoryWatcher extends EventEmitter {
641641 itemFinished ( ) ;
642642 return ;
643643 } ;
644- const handleStats = ( err2 , stats ) => {
645- if ( this . closed ) return ;
646- if ( err2 ) {
647- handleStatsError ( err2 ) ;
648- }
649- let symlinkStats ;
650- if (
651- stats . isSymbolicLink ( ) &&
652- this . watcherManager . options . followSymlinks
653- ) {
654- try {
655- symlinkStats = fs . statSync ( itemPath ) ;
656- } catch ( err3 ) {
657- handleStatsError ( err3 ) ;
658- }
659- }
644+ const handleStats = ( stats , symlinkStats ) => {
660645 if ( stats . isFile ( ) || stats . isSymbolicLink ( ) ) {
661646 if ( stats . mtime ) {
662647 ensureFsAccuracy ( stats . mtime ) ;
@@ -683,7 +668,28 @@ class DirectoryWatcher extends EventEmitter {
683668 }
684669 itemFinished ( ) ;
685670 } ;
686- fs . lstat ( itemPath , handleStats ) ;
671+ fs . lstat ( itemPath , ( err2 , stats ) => {
672+ if ( this . closed ) return ;
673+ if ( err2 ) {
674+ handleStatsError ( err2 ) ;
675+ return ;
676+ }
677+ if (
678+ stats . isSymbolicLink ( ) &&
679+ this . watcherManager . options . followSymlinks
680+ ) {
681+ fs . stat ( itemPath , ( err3 , symlinkStats ) => {
682+ if ( this . closed ) return ;
683+ if ( err3 ) {
684+ handleStatsError ( err3 ) ;
685+ return ;
686+ }
687+ handleStats ( stats , symlinkStats ) ;
688+ } ) ;
689+ } else {
690+ handleStats ( stats ) ;
691+ }
692+ } ) ;
687693 }
688694 itemFinished ( ) ;
689695 } ) ;
0 commit comments