Remote / foldkit-remote-server
Hardening
The handler applies bounded, protocol-level safeguards before or around Sources:
- a read batch may name at most
maxIdsPerEntitydistinct ids for one Entity (default1000); oversized client batches fail rather than loading unbounded rows. Remote's client cuts its batches to the same default, and to the number given inRemote.clientLayer(…, { maxIdsPerEntity }); - a request body may be at most
maxBodyBytes(default 1 MiB) where bytes are read:serveFetch's option, andbodyLimitin front of anRpcServerroute. A larger one is a 413,{ error, tooLarge: { limit } }, refused by itscontent-lengthbefore anything else, or cancelled the moment the bytes read pass the limit, and never decoded; - nested resolution is bounded by
maxDepth(default8); - the wire decoder also rejects a selection deeper than
MAX_RELATION_DEPTH(8) or more thanMAX_FIELDS_PER_REQUEST(256) fields for one Entity; - a collection relation read with no window is the Source's to bound:
foldkit-remote-drizzle'ssourcereads at mostmaxCollectionchildren of one row (default 100) and refuses a read that finds more, rather than answering a list cut short; - returned field names are copied with
Object.hasOwninto null-prototype objects, so names such as__proto__ortoStringcannot reach prototypes; - a Source's failure, a thrown error and a defect reach the caller as
Internal errorand an incident id, never in their own words, unless the Source wrote them for the caller withRemoteServer.tell(see When the server fails).
A live subscription is held to the same bounds, checked once by the handler
before any live Source or the hub sees it: more than maxIdsPerEntity ids of
one Entity (the first of each live list of it counted with them), or more
pages of one relation than a read may ask, fails the stream with
RemoteLiveRefused and nothing is read; more than MAX_LIVE_QUERIES (32) live
lists fails the wire decoder before that. That matters most for a polling
Source such as pollLive, which re-reads every subscribed row each tick. A
refusal is not truncation: the client does not reconnect it, and
liveStatus(Data, …) reads Refused. A hand-written live Source can rely on what
it is given having passed, and is responsible for any further bounds its
backend needs.