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
- Add `IPC_ENV_NAME` constant in `vite_task_ipc_shared` as the single
source of truth for the IPC env var name (shared between server and
client, not exposed to callers).
- `serve()` now returns `impl Iterator<Item = (&'static OsStr, OsString)>`
instead of a bare `OsString` name. Callers chain the iterator directly
into spawn's envs without knowing the env var name.
- `Client::from_env()` → `from_envs(envs)`: takes an env-pair iterator,
scans for the IPC env. Symmetric with server output.
- Unify temp socket prefix to `vite_task_ipc_` on both platforms.
- Drop lingering `VP_RUN_IPC` / `VP_RUN_CLIENT_NAPI` references from docs;
the env var names are now internal to server/client crates.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/runner-task-ipc/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Rust crates:
21
21
22
22
1. crates/vite_task_ipc_shared: defines the IPC message types shared between client and server. Uses wincode's zero-copy `SchemaWrite`/`SchemaRead` to minimize allocation. `Request` variants: `IgnoreInput`, `IgnoreOutput`, `GetEnv { id, name, tracked }`, `DisableCache`. Only `GetEnv` expects a `Response` (correlated via `id`); the others are fire-and-forget.
23
23
2. vite_task_server: exposes a `Handler` trait and a `serve(&handler, shutdown)` free function that binds a listener (via `interprocess`, auto-cleaned via `tempfile` on Unix) and returns the socket path / pipe name plus a single-threaded future. The future accepts new clients until the `shutdown` future resolves, then stops accepting and waits for every in-flight per-client task to drain (each drains naturally when its client closes the stream — e.g. the task process exits). Uses `FuturesUnordered` (not `spawn_local`) so the handler can be borrowed and hold `!Send` state (`Rc`, `RefCell`) without locking.
24
-
3. vite_task_client: a sync, blocking client with `&mut self` methods. Reads `VP_RUN_IPC` and `VP_RUN_CLIENT_NAPI` from the process env to set up the IPC connection, so that env var names are implementation details. Falls back to no-op if the env vars are not defined, so that it won't break the tool when it's not run by the runner.
24
+
3. vite_task_client: a sync, blocking client with `&mut self` methods. Reads IPC connection info and the client-napi dylib path from the process env (specific env var names are an implementation detail shared with `vite_task_server`). Falls back to no-op if the envs are not defined, so that it won't break the tool when it's not run by the runner.
25
25
4. vite_task_client_napi: a NAPI wrapper around the client, so that tools can require it in JavaScript/TypeScript and use it to communicate with the vite task runner.
26
26
27
27
Js Packages:
@@ -38,7 +38,7 @@ Workflow:
38
38
1.`vite_task_server` uses crate `interprocess` to create a server along with a unique name, and listens to messages from tools.
39
39
2.`vite_task` calls vite_task_server to run server for every spawn execution. and collect what's reported from tools, and respone with requested envs
40
40
3.`vite_task` embed `vite_task_client_napi` dylib and write to temp folder in the same way as `crates/fspy/src/unix/mod.rs:56`. (we should extract crates/fspy/src/artifact.rs into a separate crate)
41
-
4.`vite_task` passes VP_RUN_CLIENT_NAPI env with the path of the dylib to the tool's process env, and VP_RUN_IPC env with the unique name of the server for the tool to connect.
41
+
4.`vite_task` passes both the dylib path and the IPC connection info to the tool's process env, via env vars that `vite_task_client` knows to look up.
42
42
5. the tool is expected to use `@voidzero-dev/vite-task-client`
43
43
6.`@voidzero-dev/vite-task-client` initializes `vite_task_client_napi`, which internally reads the env vars and sets up the connection.
5.**Runner integration** — Wire into `vite_task` spawn: start server per execution, embed/extract dylib, pass `VP_RUN_IPC` + `VP_RUN_CLIENT_NAPI`.
7
+
5.**Runner integration** — Wire into `vite_task` spawn: start server per execution, embed/extract dylib, inject the IPC envs via `serve()`'s returned iterator.
8
8
6.**Cache integration** — Runner consumes the reported data (ignored inputs/outputs, requested envs, disable cache) and adjusts caching behavior.
@@ -55,17 +55,17 @@ Only when fspy is enabled (`cache_metadata.input_config.includes_auto`). No fspy
55
55
56
56
### Construction (at `ExecutionMode` build time)
57
57
58
+
`serve()` yields an env-pair iterator that the caller chains directly into the spawn's envs. The specific env var(s) used for IPC handoff are an implementation detail between the server and client crates — the runner never has to know their names.
59
+
58
60
```rust
59
-
let (name, server) =serve(IpcRecorder::new(env_config))?;
//`name` dropped here — it was only needed for envs.
64
+
//After the child is spawned, nothing else needs the IPC envs.
65
65
66
66
letfspy=FspyState {
67
67
negatives,
68
-
server, // ServerHandle<IpcRecorder>
68
+
server, // ServerHandle<'h, IpcRecorder>
69
69
};
70
70
```
71
71
@@ -80,7 +80,7 @@ struct FspyState {
80
80
81
81
**Not stored:**
82
82
83
-
-`name` — consumed once to build envs, dropped immediately.
83
+
-IPC env name/value — consumed once to build the spawn envs, dropped immediately.
84
84
-`handler` — lives inside `server.driver`'s async state; recovered by value when the driver resolves.
85
85
86
86
### Driving the server during `pipe_stdio` / `child.wait`
@@ -144,4 +144,4 @@ Earlier direction: "server doesn't care about cancellation token; it simply stop
144
144
145
145
### On `spawn()` changes (deferred)
146
146
147
-
`spawn()` will need an `extra_envs`-style parameter (or an `envs: impl IntoIterator<(impl AsRef<OsStr>, impl AsRef<OsStr>)>`) so the caller can inject `VP_RUN_IPC` without cloning `Arc<BTreeMap>`. Not part of this step.
147
+
`spawn()` will need to accept extra envs (e.g. `envs: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>`) so the caller can inject the IPC envs without cloning `Arc<BTreeMap>`. Not part of this step.
Copy file name to clipboardExpand all lines: docs/runner-task-ipc/transport.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Cross-platform IPC via `interprocess` crate:
7
7
| Unix (macOS/Linux) | Unix domain socket |
8
8
| Windows | Named pipe |
9
9
10
-
The socket path or pipe name is passed to the task process via the `VP_RUN_IPC` env var. Clients check for its presence and skip IPC gracefully if absent.
10
+
The socket path or pipe name is passed to the task process via an env var shared between `vite_task_server` and `vite_task_client` (the specific name is an implementation detail). Clients check for its presence and skip IPC gracefully if absent.
0 commit comments