fix(graph)!: enforce the node and handler return contracts instead of failing silently
provide() and run() must return an object holding every token the node
provides. A provider that returned its value bare (return client rather
than return { db: client }) booted without complaint: the token was
undefined, and the client's own properties were spread over every
request's context. That now fails, naming the node and the fix:
- providers fail the boot;
- steps fail the request;
- plugin nodes are held to the same rule for each token in provides.
A handler that returned a Fetch Response was JSON-encoded and went out
as 200 {}, with its status, headers and body lost. It now fails the
request with a TypeError that points to a plain value, @Transformer or
HttpError. Sending a Response as is can be added later without
breaking anything; taking it back would not be possible.
The check stays synchronous for a synchronous node, so a plain step
adds no microtask. Fixed health tests whose providers returned {}.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
6 files changed
+224
-7
No files matched your search
+2
-2
@@ -51,7 +51,7 @@ describe('CARD-17: health probes through app.fetch', () => {
|
||||
class SlowDb {
|
||||
async provide() {
|
||||
await new Promise<void>((resolve) => (finish = resolve));
|
||||
return {};
|
||||
return { slowDb: {} };
|
||||
}
|
||||
}
|
||||
@Module({ mountpoint: '/', controllers: [Ctl], providers: [SlowDb] })
|
||||
@@ -76,7 +76,7 @@ describe('CARD-17: health probes through app.fetch', () => {
|
||||
class Watched {
|
||||
provide() {
|
||||
started = true;
|
||||
return {};
|
||||
return { watched: {} };
|
||||
}
|
||||
}
|
||||
@Module({ mountpoint: '/', controllers: [Ctl], providers: [Watched] })
|
||||
|
||||
Reference in new issue
Block a user