It never reaches handle() — the gate returns above it — and the adapter emits request:end on its own.
Why it matters
Not that #23 is wrong. request:end is the only event carrying a real status, so a shed request that emitted nothing would be worse: the operator loses exactly the number they want under saturation, which is why the event was asked for in review.
The problem is that nothing says whether the pairing is a guarantee. LifecycleEvent does not document it, the README does not, and until now the code has upheld it by accident of having a single emitter. A consumer that opens per-requestId state on request:start and closes it on request:end works against every version shipped so far, and starts leaking half-open entries the first time a server sheds — under load, which is when it can least afford them.
Scope
Pick one and write it down:
The pair is guaranteed. Then #23 emits a request:start before the shed request:end, and so does every future emitter.
It is not. Then request:end is documented as standalone-terminal, and consumers are told to key off it alone.
Either is fine. The one that is not fine is leaving a reader to infer it from src/http/core.ts.
Adjacent to #64, which asks the same class of question — what does a consumer count — from the other direction. Worth answering both in one pass over the lifecycle docs.
Related
Found while reviewing #23. Not blocking it: the behaviour is defensible either way once it is written down.
Every terminal path in the tree today emits `request:start` and `request:end` as a pair. Expressive-Tea/green-tea#23 adds the first one that does not.
## What happens
On `contrib` at 4b04421, one subscriber on each event, five shapes of request:
| Request | HTTP | `request:start` | `request:end` |
|---|---|---|---|
| matched handler | 200 | 1 | 1 |
| unmatched route | 404 | 1 | 1 |
| handler throws | 500 | 1 | 1 |
| body over `maxBodyBytes` | 413 | 1 | 1 |
| CORS preflight | 204 | 1 | 1 |
Both come from `observedDispatch` (`src/http/core.ts:245` and `:259`), each behind its own `hasListeners` guard, so a subscriber to both always sees both.
With #23 applied, the shed request:
| Request | HTTP | `request:start` | `request:end` |
|---|---|---|---|
| over `maxConcurrentRequests` | 503 | **0** | 1 |
It never reaches `handle()` — the gate returns above it — and the adapter emits `request:end` on its own.
## Why it matters
Not that #23 is wrong. `request:end` is the only event carrying a real `status`, so a shed request that emitted nothing would be worse: the operator loses exactly the number they want under saturation, which is why the event was asked for in review.
The problem is that nothing says whether the pairing is a guarantee. `LifecycleEvent` does not document it, the README does not, and until now the code has upheld it by accident of having a single emitter. A consumer that opens per-`requestId` state on `request:start` and closes it on `request:end` works against every version shipped so far, and starts leaking half-open entries the first time a server sheds — under load, which is when it can least afford them.
## Scope
Pick one and write it down:
- **The pair is guaranteed.** Then #23 emits a `request:start` before the shed `request:end`, and so does every future emitter.
- **It is not.** Then `request:end` is documented as standalone-terminal, and consumers are told to key off it alone.
Either is fine. The one that is not fine is leaving a reader to infer it from `src/http/core.ts`.
Adjacent to #64, which asks the same class of question — what does a consumer count — from the other direction. Worth answering both in one pass over the lifecycle docs.
## Related
Found while reviewing #23. Not blocking it: the behaviour is defensible either way once it is written down.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Every terminal path in the tree today emits
request:startandrequest:endas a pair. Expressive-Tea/green-tea#23 adds the first one that does not.What happens
On
contribat4b04421, one subscriber on each event, five shapes of request:request:startrequest:endmaxBodyBytesBoth come from
observedDispatch(src/http/core.ts:245and:259), each behind its ownhasListenersguard, so a subscriber to both always sees both.With #23 applied, the shed request:
request:startrequest:endmaxConcurrentRequestsIt never reaches
handle()— the gate returns above it — and the adapter emitsrequest:endon its own.Why it matters
Not that #23 is wrong.
request:endis the only event carrying a realstatus, so a shed request that emitted nothing would be worse: the operator loses exactly the number they want under saturation, which is why the event was asked for in review.The problem is that nothing says whether the pairing is a guarantee.
LifecycleEventdoes not document it, the README does not, and until now the code has upheld it by accident of having a single emitter. A consumer that opens per-requestIdstate onrequest:startand closes it onrequest:endworks against every version shipped so far, and starts leaking half-open entries the first time a server sheds — under load, which is when it can least afford them.Scope
Pick one and write it down:
request:startbefore the shedrequest:end, and so does every future emitter.request:endis documented as standalone-terminal, and consumers are told to key off it alone.Either is fine. The one that is not fine is leaving a reader to infer it from
src/http/core.ts.Adjacent to #64, which asks the same class of question — what does a consumer count — from the other direction. Worth answering both in one pass over the lifecycle docs.
Related
Found while reviewing #23. Not blocking it: the behaviour is defensible either way once it is written down.