Skip to content

stack: effectify-file-watcher-service#17827

Merged
kitlangton merged 12 commits intodevfrom
effectify-file-watcher-service
Mar 16, 2026
Merged

stack: effectify-file-watcher-service#17827
kitlangton merged 12 commits intodevfrom
effectify-file-watcher-service

Conversation

@kitlangton
Copy link
Contributor

Restacked effectify-file-watcher-service onto dev.

Convert FileWatcher from Instance.state namespace to an Effect
ServiceMap.Service with proper scope-based lifecycle management.
The @parcel/watcher callback fires from a native C++ uv_async handle
which does not preserve Node.js AsyncLocalStorage context. Wrap the
callback in Instance.provide to restore the instance ALS context so
Bus.publish can resolve instance-scoped state and directory.
Add Instance.bind(fn) which captures the current instance ALS context
and returns a wrapper that synchronously restores it when called. This
prevents silent failures when callbacks fire outside the instance async
context (native addons, event emitters, timers).

Use it in FileWatcherService to bind the @parcel/watcher callback,
replacing the async Instance.provide workaround.
…pace

Use Effect.Config.boolean with ConfigProvider (defaults to env) so
tests can override flags via ConfigProvider.layer without module
mocking. Removes mock.module that was poisoning Flag getters and
causing cross-test pollution in config/instruction tests.
Document Instance-scoped services, Instance.bind for ALS context
in native callbacks, and the Flag → Effect.Config migration pattern.
Probe both root and git watcher readiness before asserting events so the watcher tests stop racing startup. Also make the PTY ordering test use a deterministic short-lived process and keep native PTY callbacks bound to the instance context.
- Use property shorthand `{ init }` in catchCause fallback
- Make BusUpdate.directory required (non-optional)
- Use Effect.runSync instead of Effect.runFork in synchronous callback
The deny path is synchronous once the Effect runs, but the
ManagedRuntime can take >100ms to start on slow CI runners.
Just await the result directly — bun's 30s test timeout is
the backstop if it ever hangs.
When w.subscribe() takes longer than SUBSCRIBE_TIMEOUT_MS and
eventually resolves, the subscription was left active and unmanaged.
Now the catchCause handler explicitly unsubscribes it, matching
the old withTimeout cleanup behavior.
@rekram1-node
Copy link
Collaborator

Stacks on Stacks on Stacks

@kitlangton kitlangton merged commit 9e740d9 into dev Mar 16, 2026
11 checks passed
@kitlangton kitlangton deleted the effectify-file-watcher-service branch March 16, 2026 17:18
ConanXu-math pushed a commit to ConanXu-math/opencode that referenced this pull request Mar 17, 2026
AvatarGanymede pushed a commit to AvatarGanymede/opencode-dev that referenced this pull request Mar 19, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants