valve_

Errors

ValveError, isValveError, and every error code.

ValveError

class ValveError extends Error {
  readonly name: 'ValveError';
  readonly code: ValveErrorCode;
  readonly valveId: string | undefined;
  readonly cause?: unknown;
}

valve rejects with ValveError only for its own failures. Errors thrown by your job pass through unchanged.

isValveError

function isValveError(
  error: unknown,
  code?: ValveErrorCode,
): error is ValveError;

Returns true when error is a ValveError, and, if code is given, has that code.

if (isValveError(error, 'QUEUE_FULL')) return res.status(503).end();

Codes

CodeRaised byMeaning
INVALID_OPTIONScreateValve, redisStore, run, pause, wrapFetchAn option or argument is invalid. The message names it and suggests a fix.
COST_EXCEEDS_LIMITrun, wrap, wrapFetchThe job's cost exceeds a rule's burst (GCRA) or limit (fixed window).
QUEUE_FULLrun, wrap, wrapFetchmaxQueue jobs are already waiting.
MAX_WAIT_EXCEEDEDrun, wrap, wrapFetchThe job waited longer than maxWait.
ABORTEDrun, wrapFetchThe signal aborted before the job started. cause is signal.reason.
CLOSEDrun, wrap, wrapFetchThe valve was closed before the job started.
STORE_UNAVAILABLErun, wrap, wrapFetchThe store failed and onStoreError is 'throw'. cause is the store error.
LEASE_LOSTrun, wrap, wrapFetchA global concurrency lease expired or could not be renewed.

For how to respond to each code, see Handle errors.

INVALID_OPTIONS also rejects jobs when Redis reports that their quota fingerprint does not match the pinned rate or global concurrency configuration. Its cause contains the store's mismatch error. This is a configuration failure under every onStoreError policy. See Configuration drift.

On this page