Expand description
bynk dev — build a project and serve it locally in one step.
Collapses the manual recipe (compile → cd into the generated worker dir →
wrangler dev) into a single command (proposal v0.57). The orchestration is
pre-flight → compile → select → serve, and almost every piece is reused:
compiler::resolve for bynkc, the doctor Deploy
capability for the Node + wrangler gate, and probe for locating
wrangler with the same provenance ordering doctor reports.
The serve step runs wrangler dev in local mode (Miniflare), which
simulates KV / Durable Objects / queues keyed by binding name — so no
namespace provisioning is needed and the generated wrangler.toml is served
untouched (proposal §1, D4). Everything wrangler-specific is encapsulated
here so the serve step can later be swapped for a first-party workerd
server without touching the rest (proposal §4).
Since #552 the step is one wrangler dev per context, not one per
project: the processes discover each other through wrangler’s dev registry
and wire the emitted [[services]] bindings between themselves, so a
cross-context call resolves locally. That makes the driver a supervisor of N
children rather than a hand-off to one — hence the port allocation
(allocate), the joint teardown (terminate, private), and the plural
selection rule (select_contexts) that replaced ADR 0096 D3’s ambiguity
error.
Re-exports§
pub use crate::workers::SelectError;pub use crate::workers::compile_once;pub use crate::workers::discover_workers;pub use crate::workers::prepare_build_dir;pub use crate::workers::select_contexts;pub use crate::workers::wrangler_command;
Structs§
- DevOptions
- Parsed
bynk devflags (the projectPATHis resolved intoproject_rootbefore we get here). - Served
Context - One served context in a
DevEvent::Servingevent. - Serving
- One worker to serve: its dasherised context dir, its HTTP port (
None= let wrangler choose, the lone-worker default), its inspector port, and whether the inspector was asked for (--inspect) rather than only allocated so the contexts’ default inspectors do not collide (#1954). - StandIn
- Interop I5 (#1972): one stand-in
bynk devruns for a foreign Worker that a served context binds: the Worker’s name, and the context’s bindings to it. It runs inside that context’s ownwrangler dev, as a second-cconfig, under a name of its own (stand_in_name).
Enums§
- DevEvent
- One lifecycle event of a
bynk dev --format jsonsession (#2094): a stable, line-delimited interface for the editor and CI scripts, so neither has to parse the human report, whose wording is UX and changes. Serialised with aneventtag in snake_case. A consumer should ignore fields and events it does not know: new ones may be added, existing ones keep their meaning. - DevFormat
bynk dev --format(#2094).
Constants§
- STAND_
IN_ CONFIG - The config a context with stand-ins is served from: its generated
wrangler.tomlwith each binding to a foreign Worker pointed at the stand-in, beside the original somainresolves the same.
Functions§
- allocate
- Allocate a port per worker (#552):
wrangler devbinds one port per process, so serving N contexts means N distinct ports, assignedbase + iover the deterministic worker order. - event_
line - One event as its JSON line (no trailing newline).
- foreign_
services - Interop I5 (#1972): the Service Bindings in a generated
wrangler.tomlwhose target is none ofproject_workers, as(binding, worker)in binding order: the bindings to foreign Workers, by the rulebynk deployuses. An unreadable config has none; the serve step reports it. - needs_
wrangler_ warmup - #1957: whether to install wrangler once before spawning the contexts. Only
an npx resolution installs on first use, and only several spawns at once
race each other in npm’s
_npxcache; a lone context installs alone. - preflight_
failure_ message - The text
bynk devprints when the deploy pre-flight fails: a lead line plus doctor’s own human report, so the remedy lines are identical tobynk doctor. Pure (no I/O) so this deterministic surface is pinned by a golden (§5), unlike the non-deterministicwrangler devstream. - run
- Orchestrate a local dev session: pre-flight, compile, select the worker, and
hand off to
wrangler dev. Returns wrangler’s own exit code on a clean hand-off, or a pre-flight/build failure code before serving. - serving_
event - The
DevEvent::Servingevent for an allocation. A lone worker left on wrangler’s default (port: None) reports the port it actually gets: a-- --port Npassthrough, else wrangler’s 8787. - serving_
report - The start-up report: which context answers on which URL, plus the inspector
notice under
--inspect. Pure and deterministic, so it is golden-pinned in the style of ADR 0096 §Exit — unlike thewrangler devstreams it precedes. - stand_
in_ files - The stand-in’s
wrangler.tomlandindex.js. It answers every request withbynk_emit::emitter::wrangler::FOREIGN_SERVICE_DOUBLE_STATUSand a body saying what it is and how to reach the real Worker, as the integration test harness’s stand-in does. - stand_
in_ name - The Worker name
context‘s stand-in forworkerruns under. Not the foreign Worker’s own: a-cconfig’s Worker also registers in wrangler’s dev registry, which every localwrangler devshares (verified on 4.149.0), so under the real name it would answer other sessions’ bindings to that Worker and, once stopped, could leave a stale entry for--local-workerto connect to. The context’s binding is pointed at this name instead (point_at_stand_ins). - stand_
in_ report - The start-up lines naming each stand-in, so a 503 from one is never a mystery. Empty when there are none.
- stand_
ins - Interop I5 (#1972, track §11 Q8): the stand-ins one context’s
wrangler devruns, one per foreign Worker it binds, in Worker order, less thoselocalnames. Verified on wrangler 4.149.0: a second-cconfig’s Worker answers its primary’s binding to it, and without one a binding to a Worker that is not running answers 503 (“Worker … not found”). - wrangler_
age_ notice - #1732: the warning
bynk devprints before serving with a wrangler older thanbynk_emit::WRANGLER_MIN. Itsworkerdrefuses the pinned compatibility date outright, and wrangler’s own error says nothing about Bynk, so this names the cause and the fix first. A warning, not a refusal: the version isdoctor’s judgement, and the wrangler itself has the last word.Nonewhen the wrangler is new enough, or can’t be versioned (npx).