fix(graph)!: fail boot when a node needs the token it provides (GitHub #43)
topoSort validated each need with producedBy.has(key), and the visit skipped a dependency whose producer was the node itself. So a step with needs: ['user'] and provides: ['user'], and nothing else providing user, passed the graph check and booted. At request time it read a value nobody had written, where every other missing dependency fails at boot. The check now treats a node's own token as missing unless it is seeded. The issue also allowed "provided by another node", but since CARD-18 (GitHub #35) a token has exactly one producer, so a second node that provides it fails boot on its own; the self-producer is the only producer there can be. A seeded token (req, params) still satisfies the need, because the step reads the seed from the context before its output is merged over it. The visit keeps skipping the node itself for that case, so it is not reported as a cycle. overrides do not exempt the node. They replace a runner after finalizeGraph has run topoSort, and change no needs, so the graph check sees the same node either way. BREAKING CHANGE: an app with a node that needs a token only it provides now fails createApp with "missing dependency: <token> needed by <node> — it provides '<token>' itself". Remove the token from the node's needs, or move the work that produces it into a separate provider or step. Refs: GitHub #43 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
4 files changed
+47
-2
No files matched your search
@@ -115,6 +115,16 @@ npm treats versions as semver and semver forbids leading zeros.
|
||||
browsers from reusing a file for a lifetime they guessed from `Last-Modified`. To keep the old
|
||||
behaviour, set `static: { cacheControl }` to whatever your proxy expects.
|
||||
|
||||
- **A node that needs the token it provides fails `createApp`** (GitHub #43). The graph check
|
||||
skipped a dependency whose producer was the node itself, so a step with `needs: ['user']` and
|
||||
`provides: ['user']` booted, and at request time read a value nobody had written. It now fails
|
||||
like any other missing dependency: `missing dependency: user needed by auth — it provides 'user'
|
||||
itself`. Since a token has one producer (GitHub #35), no other node can supply it; only a seeded
|
||||
token (`req`, `params`) still satisfies a node's own need, because the node reads the seed.
|
||||
`overrides` do not exempt the node: they replace its runner after the graph is checked. To
|
||||
migrate, remove the token from the node's `needs`, or move the work that produces it into a
|
||||
separate provider or step the node needs.
|
||||
|
||||
### Added
|
||||
|
||||
- **Health probes: `createApp({ health: true })`** (#115). Off by default. `GET`/`HEAD /__live__`
|
||||
|
||||
Reference in new issue
Block a user