Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix(studio): recover from source watcher errors

kashorinc40e9deadacf
diff --git a/packages/studio/src/server.ts b/packages/studio/src/server.ts
index 7196a0d4..49a6b9f4 100644
--- a/packages/studio/src/server.ts
+++ b/packages/studio/src/server.ts
@@ -89,10 +89,15 @@ export function studioPlugin(options: StudioPluginOptions): Plugin {
const directory = dirname(absolute);
if (watched.has(directory)) return;
try {
- watched.set(directory, watch(directory, (_event, filename) => {
+ const watcher = watch(directory, (_event, filename) => {
const changed = filename === null ? undefined : resolve(directory, filename.toString());
if (!mutating && (changed === undefined || watchedFiles.has(changed))) schedule();
- }));
+ });
+ watcher.on("error", () => {
+ watcher.close();
+ if (watched.get(directory) === watcher) watched.delete(directory);
+ });
+ watched.set(directory, watcher);
} catch {
// Some Hosts may report virtual Source ids. They are still recompiled
// whenever a real Source revision is scheduled; they simply emit no file event.