You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#906 - Add watchPaths option to McpHub for file change detection (#1755)
* #906 Add watchPaths option to McpHub for file change detection
* #906 Refactor file watcher management in McpHub
add support multiple watchers per server.
modified the setupFileWatcher method to properly handle asynchronous operations and prevent unhandled promise rejections.
error handling now includes specific error messages that identify exactly where the error occurred.
---------
Co-authored-by: Matt Rubens <[email protected]>
// we use chokidar instead of onDidSaveTextDocument because it doesn't require the file to be open in the editor. The settings config is better suited for onDidSave since that will be manually updated by the user or Cline (and we want to detect save events, not every file change)
570
-
constwatcher=chokidar.watch(filePath,{
599
+
console.log(`Setting up build/index.js watcher for ${name} MCP server...`)
600
+
// we use chokidar instead of onDidSaveTextDocument because it doesn't require the file to be open in the editor
601
+
constindexJsWatcher=chokidar.watch(filePath,{
571
602
// persistent: true,
572
603
// ignoreInitial: true,
573
604
// awaitWriteFinish: true, // This helps with atomic writes
574
605
})
575
606
576
-
watcher.on("change",()=>{
607
+
indexJsWatcher.on("change",async()=>{
577
608
console.log(`Detected change in ${filePath}. Restarting server ${name}...`)
578
-
this.restartConnection(name)
609
+
try{
610
+
awaitthis.restartConnection(name)
611
+
}catch(error){
612
+
console.error(`Failed to restart server ${name} after change in ${filePath}:`,error)
613
+
}
579
614
})
580
615
581
-
this.fileWatchers.set(name,watcher)
616
+
watchers.push(indexJsWatcher)
617
+
}
618
+
619
+
// Update the fileWatchers map with all watchers for this server
0 commit comments