mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
fix: Use parent transaction for findOrCreate after-commit hook (#8173)
This commit is contained in:
@@ -83,7 +83,12 @@ class Event extends IdModel<
|
||||
options: SaveOptions<InferAttributes<Event>>
|
||||
) {
|
||||
if (options.transaction) {
|
||||
options.transaction.afterCommit(() => void globalEventQueue.add(model));
|
||||
// 'findOrCreate' creates a new transaction always, and the transaction from the middleware is set as its parent.
|
||||
// We want to use the parent transaction, otherwise the 'afterCommit' hook will never fire in this case.
|
||||
// See: https://github.com/sequelize/sequelize/issues/17452
|
||||
(options.transaction.parent || options.transaction).afterCommit(
|
||||
() => void globalEventQueue.add(model)
|
||||
);
|
||||
return;
|
||||
}
|
||||
void globalEventQueue.add(model);
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import "sequelize";
|
||||
|
||||
declare module "sequelize" {
|
||||
interface Transaction {
|
||||
parent?: Transaction;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user