Forráskód Böngészése

Fix watcher stop failing when watcher object is null but isWatching is true

- Backend was checking 'this.watcher && this.isWatching' causing stop to fail
- When watcher object was null but status showed isWatching=true, stop returned error
- Now checks isWatching first and handles missing watcher object gracefully
- Always sets isWatching=false and clears watcher reference when stopping
- Prevents inconsistent state between watcher object and isWatching flag
Timothy Pomeroy 3 hete
szülő
commit
6bc6353ecb
1 módosított fájl, 11 hozzáadás és 2 törlés
  1. 11 2
      apps/service/src/watcher.service.ts

+ 11 - 2
apps/service/src/watcher.service.ts

@@ -517,8 +517,17 @@ export class WatcherService implements OnModuleDestroy {
   }
 
   async stop() {
-    if (this.watcher && this.isWatching) {
-      await this.watcher.close();
+    // If status shows we're watching, force stop regardless of watcher object state
+    if (this.isWatching) {
+      if (this.watcher) {
+        try {
+          await this.watcher.close();
+        } catch (error) {
+          this.logger.warn(`Error closing watcher: ${error.message}`);
+        }
+      }
+      
+      this.watcher = null;
       this.isWatching = false;
       this.eventsGateway.emitWatcherUpdate({ type: 'stopped' });