v4.2.1
Fixed
-
query.createEntityleaked a pooled connection on every failed insert.
When no transaction was passed it opened one, and finished it only on the happy
path — there was norollbackanywhere in the helper. A rejectedsave()(a
unique or foreign-key violation, a NOT NULL, an invalid enum) unwound past the
commit and left the transaction open.In sequelize 6 a pooled connection is bound to the
Transactionand only
commit()orrollback()hands it back, so nothing released it:pool.max
failed inserts — 5 by default — exhausted the pool, after which every query in
the process failed withSequelizeConnectionAcquireTimeoutErroruntil it was
restarted. On the database side the backend sat in
idle in transaction (aborted)indefinitely.Ownership is now all-or-nothing, decided by a single flag used for both the
commit and the rollback so the two cannot select different sets of calls. Only
the call that opened the transaction finishes it; a caller-supplied transaction
and the nested relation creates that inherit it are untouched, exactly as
before. A rollback that fails is swallowed so it cannot replace the error that
caused it.Anyone who cannot upgrade can own the lifecycle from outside, which closes the
leak with no dependency change:const entity = await Model.sequelize!.transaction(transaction => createEntity<T, I>(Model, data, fields, transaction), );
About
@imqueue/pg-sequelize turns a query described as data — filters, paging, ordering and the requested fields — into one efficient Sequelize statement, with database views as models and the Postgres index options Sequelize cannot express. Part of the @imqueue framework for Node.js & TypeScript microservices.
- Docs: https://imqueue.org/
- Guide for AI assistants / LLMs: https://imqueue.org/llms.txt
- Commercial license & support: https://imqueue.com/
npm i @imqueue/pg-sequelize