Plug & Play Performance Guide
Plug & Play features only help if they stay operationally boring in production.
This page documents the non-negotiable runtime rules for every Plug & Play surface.
State ownership
- prefer invocation-scoped state
- prefer request-scoped memoization over process-global caches
- add explicit cleanup for any long-lived registry or retained history
Retention limits
- no unbounded arrays or maps for job history, notifications, or loader caches
- add TTL or capacity limits when retention is necessary
- keep retained payload metadata minimal
Observability
- emit structured logs through
Logger.* - use low-cardinality metrics
- expose normalized stage or status values that can be aggregated easily
Validation
Before shipping a Plug & Play runtime feature, verify:
npm testnpm run type-checknpm run lintnpm run -s coverage:patch- explicit smoke checks for both
zin sandzin s --wg
Examples of good boundaries
Good
ts
const payload = await SecurePayload.decode(raw, { decryptor: 'default' }).decrypt().json().typed();The pipeline state is dropped once the promise resolves.
Bad
ts
globalDecodedPayloads.push(payload);That turns a reusable workflow into an unbounded memory sink.