stopgap
pgrx deployment layer for versioned TypeScript/JavaScript function bundles backed by PLTS.
stopgap · pgrx deployment layer for versioned TypeScript/JavaScript function bundles backed by PLTS.
Overview
PostgreSQL · 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | plts |
Usage
Sources:
stopgap is a versioned deployment and invocation layer for TypeScript/JavaScript function bundles executed by the companion plts procedural language. It keeps environments, deployment history, activation, diffing, and rollback in PostgreSQL while application code is addressed by a path such as api.coolApi.myFn.
Install and Invoke
Both extensions are untrusted and require superuser installation. Install plts first, then stopgap:
The current upstream direction keeps named TypeScript exports under a project-local stopgap/ tree and recommends the CLI for deployment validation and ergonomics:
Runtime and Management Surface
stopgap.call_fn(path, args)resolves a deployed named export and returns non-null JavaScript values asjsonb; JavaScriptundefinedandnullbecome SQLNULL.stopgap.status,stopgap.deployments,stopgap.diff, andstopgap.rollbackinspect and manage environment state.stopgap.queryhandlers run with a read-only database context and rejectdb.exec;stopgap.mutationand regularpltshandlers receive a read-write context.- Database operations initiated through the handler context run in the same PostgreSQL transaction as the calling SQL statement.
Security and Change Boundaries
- TypeScript/JavaScript runs inside the database trust boundary. Review bundle provenance, dependency locking, SQL privileges, schema access, resource limits, error handling, and observability before executing application-supplied code.
- Keep deploy, activation, and rollback privileges separate from ordinary invocation. Treat an environment change as a database release, with review, backups, smoke tests, and a tested rollback target.
- A function can hold locks and consume backend CPU or memory for the duration of the calling transaction. Set timeouts and keep network or long-running work out of hot transactions.
- The reviewed README says the product was being course-corrected in March 2026 and labels several SQL signatures as target shapes during migration. Pin version
0.1.3, verify the installed signatures, and do not automate against roadmap text alone. - Compiler and runtime semantics are shared with the installed
pltsversion. Test TypeScript type checking, module resolution, serialization, transaction rollback, and upgrades as one compatibility unit.