Repository navigation
stitchkit v0.111.0
·
46 commits
to master
since this release
⚠️ Breaking changes
Who must act: applications whose raw routes call parseBody on JSON larger than 1 MiB, and applications whose OAuth clients send /register or /token bodies larger than 64 KiB. Everyone else changes nothing.
stitchkit/server—parseBodyreads at most 1 MiB by default and returnsnullfor a larger body, where it used to read any size into memory. An unbounded read of a raw route's body is a hole in the bounded-everything rule (I10), andmaxJsonBodyBytesnever covered raw routes. Before:await parseBody(req, Schema)parsed a body of any size; after: pass the limit your route needs,await parseBody(req, Schema, { maxBytes: 8 * 1024 * 1024 }). → ADR 0262
Affects:stitchkit/serverparseBodystitchkit/tools—mountOAuthProviderreads at most 64 KiB of a/tokenor/registerbody and answers413withinvalid_requestfor a larger one, where it used to read any size. Before: no limit; after: the default is 64 KiB andmountOAuthProvider({ ..., maxRequestBodyBytes: 256 * 1024 })raises it. → ADR 0262
Affects:stitchkit/toolsmountOAuthProvider
Added
stitchkit/observability:request.payloadMaxBytessets how much of a request body the audit row reads withincludePayload(default: the handler'smaxJsonBodyBytes, or 1 MiB), and an event whose body was larger carriespayloadTruncated: truebeside itsnullpayload.stitchkit/tools:mountOAuthProvider({ maxRequestBodyBytes })sets the most bytes/tokenand/registerread of a request body (default 64 KiB).stitchkit,stitchkit/http:readBoundedBody(source, { maxBytes, signal?, limitError, abortError? })reads aReadableStream<Uint8Array>, an async byte iterable or anullbody into bytes without reading pastmaxBytesplus one chunk. The source is cancelled when the limit is crossed and when the signal aborts, an abort is honoured before the first read and while a read never settles, and the caller picks both errors. A consuming project no longer needs its own copy; the request-text, unix-client, connection-response, capped-download and sandbox-gateway readers of the framework now run on the same chunk loop. → ADR 0262stitchkit/server,stitchkit/node:defineRequestIngress<T>(name)returns a typed key whoseattach(request, value)is called by the code that builds aRequest(a local socket ingress, a relay) and whosefrom(ctx)an endpoint,authorize,beforeHandleoronErrorreads. A header,clone()andnew Request(request)carry nothing; a request from another ingress has no value.ctx.reqis documented, and tested on every HTTP context, as the veryRequestthe handler received. → ADR 0261stitchkit upgradeprints a second section, Fixes that touch this project, with the same verdicts as breaking items for every fix of the range that names what it touches (fixesandfixesWithoutAffectsin--json);release:checkrequires the**Affects:**line on a Fixed item that leads with a public entrypoint, from the release after 0.110.6. → ADR 0263
Fixed
stitchkit/server,stitchkit/node: acreateUnixClientTransportrequest that is aborted while its body is being read rejects with the abort reason at once instead of waiting for the next chunk of a stalled source, and cancels the body when it crosses the request size limit.
Affects:stitchkit/server,stitchkit/nodecreateUnixClientTransportstitchkit/server: withobservability.includePayload, the audit row reads the cloned request body up topayloadMaxBytes(by default the handler'smaxJsonBodyBytes, or 1 MiB; an endpoint's ownmaxJsonBodyBytesis not known when the body is cloned, so setpayloadMaxBytesfor endpoints that accept more) and cancels that branch there; before, the clone branch of the body stream drained the whole body into memory even when the handler's own branch was cut atmaxJsonBodyBytes.
Affects:stitchkit/servercreateServer(observability.includePayload)