Skip to main content
loadwise rel finds code that fails at runtime or under concurrency: unhandled rejections, swallowed errors, races, missing timeouts and idempotency, transactions that escape their client, unsafe migrations and breaking API changes. It shares the source check of loadwise perf, so project discovery, policy, config, engines, baselines and fix flags are the same, and loadwise check type-checks the project once for both. Run it with npx loadwise rel -p tsconfig.json; npx loadwise rel --help lists every flag. loadwise rel --fail-on contract enforces only pg-transaction-on-pool.

Source rules

Some rules moved here from the performance and maintainability checkers and kept their ids, so existing // loadwise-reviewed comments, --ignore flags and config rules entries keep working. csharp-async-void and the python-, go-, java-, csharp-, kotlin- and rust- rules come from loadwise rel polyglot, which needs the optional ast-grep executable.
  • assignment-in-condition (high): A condition assigns with = where a comparison was probably meant.
  • async-array-predicate (high): A native synchronous array predicate definitely returns a promise.
  • async-callback-unhandled-rejection (high): An async callback given to an event emitter, timer or scheduler has no error handling, so a rejection is unhandled.
  • async-promise-executor (high): The built-in Promise constructor is given an async executor.
  • async-route-unhandled-rejection (high): An Express 4 async route handler has no error handling, so a rejection never reaches the error middleware.
  • browser-not-closed (high): A Playwright or Puppeteer browser is not closed in a finally block, so an error leaves the process running.
  • check-then-update-race (high): A Mongoose or Sequelize document’s numeric field is read, changed in JavaScript and saved without a transaction, losing concurrent updates.
  • child-process-without-error-listener (high): A spawned child process has no ‘error’ listener, so a failed spawn crashes the parent process.
  • crlf-unsafe-line-split (medium): Splitting file text on a bare newline leaves carriage returns on CRLF lines and can change exact comparisons.
  • csharp-async-void (high): An async void method cannot be awaited and can crash the process on unhandled exceptions.
  • csharp-disposable-without-using (medium): A C# stream, connection or other IDisposable is created without using, so an exception leaks it.
  • csharp-sync-task-wait-in-async (medium): A C# async method uses Result or Wait() on a recognized Task parameter.
  • db-pool-client-not-released (high): A locally checked-out database connection can leave its scope without being released.
  • discarded-error-result (high): A call discards a typed Either or Result that can carry a failure as a value.
  • discarded-file-write-count (high): A chunk-writing loop discards the byte count returned by a low-level Node write.
  • drizzle-unfiltered-write (critical): A Drizzle update or delete executes without an effective where clause.
  • drizzle-write-preflight (medium): A separate existence check before a Drizzle write can race with another request.
  • error-logged-without-stack (low): A catch block logs only error.message and carries on, so the stack trace is lost.
  • error-rethrown-without-cause (low): A catch block throws a new error without the caught one, so the original message and stack are lost.
  • file-handle-not-closed (high): A FileHandle from fs/promises open() is not closed on every path, leaking a file descriptor.
  • find-then-create-race (high): A lookup by key is followed by an insert with that key, with no unique constraint to stop duplicates.
  • floating-promise (high): A promise-returning call is neither awaited, returned nor handled, so its failure goes unseen.
  • go-defer-before-error-check (high): A Go defer closes a resource before its error is checked, so a failed open dereferences nil.
  • go-error-discarded (high): A Go error result is assigned to the blank identifier and never checked.
  • go-http-call-without-deadline (low): A Go HTTP handler calls net/http without a local request timeout or deadline.
  • go-http-response-body-not-closed (medium): A Go function reads the contents of a locally owned HTTP response without closing its body.
  • go-sql-rows-leaked (high): A Go database/sql Rows iterator exits successfully before exhaustion without closing.
  • go-sql-rows-unchecked-err (high): A Go database/sql Rows loop returns success without checking an iteration error.
  • http-call-without-timeout (high): A fetch or axios call has no timeout or abort signal.
  • interval-not-cleared (medium): A setInterval handle is discarded or never cleared, so the timer outlives its owner.
  • invalid-typeof-comparison (high): A typeof result is compared to a string typeof never returns, so the check never matches.
  • java-resource-without-try (high): A Java stream, reader or connection is opened outside try-with-resources, so an exception leaks it.
  • java-shared-date-format (medium): A shared Java SimpleDateFormat is used without visible synchronization.
  • json-parse-unguarded (medium): JSON.parse runs on outside input with no try/catch, so malformed input throws where it is not handled.
  • kotlin-run-blocking-in-suspend (low): A direct coroutine runBlocking call blocks the thread of a suspend function.
  • loop-index-past-length (high): A loop runs its index up to and including length, so the last pass reads past the end.
  • lossy-same-file-text-rewrite (high): A caller-selected file is decoded permissively as UTF-8 and overwritten after a text edit.
  • mongoose-aggregate-uncast-id (high): A Mongoose aggregate $match compares _id to an uncast string instead of an ObjectId.
  • nan-comparison (high): A value is compared to NaN with an equality operator, which is never true.
  • next-server-env-in-client (high): A ‘use client’ file reads a process.env variable without the NEXT_PUBLIC_ prefix, so it is unavailable in the browser by default.
  • numeric-array-default-sort (medium): An array of numbers is sorted without a comparator.
  • parse-failure-resets-file (high): A write after a read or parse failure can replace unreadable contents at the same path.
  • payment-missing-idempotency-key (high): A Stripe call that moves money has no idempotency key, so a retry can charge or pay out twice.
  • pg-advisory-lock-session (high): A PostgreSQL session can return to the pool while it holds an advisory lock.
  • pg-listen-session (high): A PostgreSQL listener connection can return to the pool while it is still subscribed.
  • pg-transaction-on-pool (critical): A transaction statement is sent to a pool, so its statements can run on different connections.
  • pool-without-connection-timeout (medium): A pg Pool or Client sets no connectionTimeoutMillis, so its default of 0 waits for a connection forever.
  • prisma-dependent-writes (high): Adjacent Prisma creates pass a value from the first record into the next write.
  • prisma-read-modify-write (critical): A Prisma read feeds a numeric update of the same row, losing concurrent updates.
  • prisma-transaction-client-escape (critical): A Prisma call inside an interactive transaction uses the outer client instead of the transaction client.
  • promise-return-escapes-catch (high): Returning a promise directly from a protected try block can bypass its catch on rejection.
  • python-bare-except (medium): A bare except also catches SystemExit and KeyboardInterrupt, hiding shutdowns and bugs.
  • python-file-not-closed (medium): A Python function returns the contents of a locally opened file without closing its handle.
  • python-mutated-mutable-default (medium): A function directly mutates an object shared as a default argument between calls.
  • python-requests-without-timeout (low): A direct Python requests call has no visible timeout or streaming policy.
  • python-swallowed-exception (medium): A Python except block only passes, so the failure is dropped silently.
  • query-runner-not-released (critical): A TypeORM QueryRunner is not released in a finally block, so an error leaks its pooled connection.
  • react-async-effect-callback (medium): An async function is passed to useEffect, so its promise is treated as the cleanup function and its errors go unhandled.
  • react-effect-sets-state-every-render (high): An effect with no dependency array sets state to a new value on every run, so the component re-renders forever.
  • react-list-missing-key (medium): An element or fragment returned from .map() has no key prop, so React cannot track items when the list changes.
  • react-state-mutated-in-place (high): A useState value is mutated in place and passed to its own setter, so React sees the same reference and skips the re-render.
  • redis-incr-then-expire (medium): A Redis counter increment and its expire on the same key are two round trips and not atomic.
  • request-number-unvalidated (medium): A number parsed from request input reaches a query or calculation with no NaN or range check.
  • retry-without-backoff (medium): A retry loop calls the network again with no delay between attempts.
  • return-in-finally (high): Returning from finally can replace a pending return value or suppress a thrown error.
  • return-newline (high): A line break after return ends the statement before the apparent return value.
  • rust-blocking-std-in-async (medium): An async Rust function directly executes a synchronous standard-library call.
  • rust-mutex-guard-across-await (medium): A standard Rust MutexGuard remains live across an await.
  • rust-unwrap-in-production (medium): Rust code outside tests calls unwrap(), turning an Err or None into a panic.
  • same-file-stream-truncation (high): Connected Node read and write streams use the same file with truncating flags.
  • sql-insert-truncated-at-semicolon (high): A SQL dump parser ends INSERT values at a semicolon inside quoted text.
  • stream-pipe-unhandled-error (high): A stream is piped with .pipe() and no error handling, so a stream error can crash the process or leak the file.
  • swallowed-error (medium): A catch block drops the error and the code after the try carries on as if it succeeded.
  • switch-not-exhaustive (medium): A switch over a union or enum has no default and misses members, so the missing value leaves the result undefined.
  • test-cleanup-after-await (medium): A test waits before cleaning up a local resource, so a rejection can leave it running.
  • throw-non-error (medium): A string, number or object literal is thrown instead of an Error, so there is no stack trace.
  • typeorm-transaction-client-escape (critical): A write inside a TypeORM transaction goes through a repository not bound to it.
  • unbounded-promise-all (high): Promise.all runs over an unbounded collection without a concurrency limit, risking memory spikes or downstream saturation.
  • uncaught-exception-continues (high): An uncaughtException handler neither exits nor rethrows, so the process keeps running in an undefined state.
  • unchecked-json-cast (medium): Parsed JSON, a response body or a request body is cast to a type without a schema check or type guard.
  • unguarded-boundary-access (medium): A nested property is read from outside input or a lookup that can be missing, so absent data throws a TypeError.
  • unreachable-code (medium): Statements follow a return, throw, break or continue in the same block and never run.
  • upload-without-size-limit (high): A multer or Nest upload interceptor has no file size limit.
  • webhook-missing-idempotency-check (medium): A webhook route inserts rows without visible atomic deduplication by event ID.

Migration safety

npx loadwise rel migrations reads Prisma, Drizzle, TypeORM, Knex and Sequelize migrations (SQL or code) and flags potentially unsafe schema changes. It reads files only. --dialect postgres|mysql|sqlite|sqlserver selects the rule set, --json gives structured output, and --ignore RULE skips a rule. The older loadwise perf migrations and loadwise perf contracts still work and print a note pointing to rel. SQLite checks detect drops and renames on existing tables. A rebuild avoids the drop finding when it disables foreign keys before an explicit transaction, uses an unfiltered INSERT … SELECT * with an implicit destination column order, swaps the replacement into place, and runs a schema-wide foreign_key_check immediately before committing and re-enabling enforcement. Confirm the check results, column mapping, constraints and indexes separately. A rebuild that copies matching column lists (INSERT INTO new (a, b) SELECT a, b FROM old), as Prisma and drizzle-kit generate, gets a contextual drop finding instead, since columns left out of the copy are discarded. Index, view and trigger statements, pragmas and VACUUM are read as safe. SQLite-specific syntax outside the supported subset is identified as migration-unparsed. A project that lists a Postgres or MySQL driver next to a SQLite driver is checked as Postgres or MySQL; pass --dialect sqlite to check it as SQLite. Hosted Turso and libSQL are not inferred as SQLite. SQLite migration contents must resolve inside the project root by default. Pass an external file or directory explicitly to check it. Dialect discovery can still inspect configured directories and provider metadata before applying this content boundary. Prisma and Drizzle migrations with a known provider use their own dialect. For generic migrations in a project with multiple plausible dialects, pass --dialect explicitly. For SQL Server, use --dialect sqlserver to select the dialect explicitly. For otherwise unhinted migrations, a production SQL Server driver takes precedence over a development-only SQLite driver, and a SQL Server-only package hint yields to a known framework dialect. If package metadata leaves the dialect ambiguous, pass --dialect explicitly. Loadwise checks literal T-SQL and TypeORM query strings for a supported subset of offline rowstore index builds on existing tables. SQL Server migration files resolve inside the selected roots. Pass an external migration file or directory explicitly to check it. Unsupported statements are skipped without a rewrite. Only new migrations fail the run; older ones are contextual (counted, listed with --include-contextual, never exit 1). In CI, --changed-since origin/main enforces only migrations the branch adds or changes (plus untracked files) and needs a full-history checkout (fetch-depth: 0). For a project with existing migrations, accept them once:
--baseline FILE reads or writes another path. Exit codes: 0 passed, 1 findings in enforced migrations, 2 invalid input.

API contract safety

For Protobuf, Loadwise compares removed RPCs and field numbers reused with a proven incompatible wire type. It recognizes a moved RPC when its qualified name uniquely moves between files in the same directory. Imports are read from the directory of the importing file or the checked project root for each revision. Malformed affected sources and unavailable required imports mark the comparison incomplete. Repeated fields, RPC signatures, and broader source compatibility are outside this comparison. For tRPC, Loadwise compares named exported routers built with literal router calls, mergeRouters, and resolvable local bindings. It checks removed procedures, procedure kinds, and proven narrowing for supported Zod primitive, literal, object, and string-minimum inputs. Dynamic router members, wildcard re-exports, and unsupported validators are reported as unknown. Malformed affected sources and unreadable required local modules mark the comparison incomplete. npx loadwise rel contracts [--changed-since REF] [--json] compares the working tree with the merge base of REF (default HEAD) and flags changes that break API clients; loadwise check --changed-since REF includes the same findings in the reliability report. Both respect workspace selection, ignored paths and rules, configured rule levels and minimum impact, and need a full-history checkout so the ref resolves. It compares OpenAPI and Swagger JSON (openapi.json, swagger.json; YAML is skipped with a note), GraphQL SDL (*.graphql, *.gql; query documents are skipped) and NestJS classes used as @Body() types or controller return types (also @ApiResponse({ type })) in *.controller.ts, read through relative imports. Only property names, ?, @IsOptional() and the written type text are compared, and properties inherited from a base class in a relative import count as the class’s own. A removed request property is flagged only when the project builds a ValidationPipe with forbidNonWhitelisted: true. Removals point at the line in the old version; a new version next to the old one (/v2/users beside /v1/users) is not flagged.
  • api-enum-value-removed (high): An enum value or string-literal option that clients could send was removed.
  • api-removed-field (high): A response field, GraphQL type, field, argument or union member, or returned DTO property was removed.
  • api-removed-operation (critical): An OpenAPI operation or a GraphQL Query, Mutation or Subscription field was removed.
  • api-required-input (high): A request field, parameter or GraphQL argument is new and required, or became required.
  • api-type-changed (high): A field or parameter changed type, or a GraphQL type changed nullability in a breaking direction.