Skip to content

Conversation

noahfraiture
Copy link

Hi,

This PR replaces fs.watch with chokidar.watch to address feature request #1549. However, the current implementation hangs unless the watcher is explicitly closed. I couldn't determine the cause of this behavior and would appreciate any insights or suggestions from the team regarding the application's behavior.

Thank you!

@rekram1-node
Copy link
Collaborator

@noahfraiture I can help look into this, can you outline the issues you were having?

@noahfraiture
Copy link
Author

@noahfraiture I can help look into this, can you outline the issues you were having?

Sure, so with this code

        const watcher = chokidar.watch(app.info.path.cwd, { ignoreInitial: true })
        log.info('watcher created')
        watcher.on('change', file => {
          log.info("change", { file, event: "change" })
          if (!file) return
          // for some reason async local storage is lost here
          // https://github.com/oven-sh/bun/issues/20754
          App.provideExisting(app, async () =>
            Bus.publish(Event.Updated, { file, event: "change", })
          )
        })
        log.info('return watcher')
        return { watcher  }

We successfully get the log message saying the watcher is created, however opencode never actually start, we are stuck at the last logs INFO 2025-08-15T08:44:06 +2ms service=default cmd=["go","run","./main.go"] tui. But if we close the watcher before returning it, it works correctly.
When we use fs.watcher it works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants