feat(transactions): Add afterCommit hooks for transactions #9287
Pull Request check-list
Please make sure to review and check all of these items:
Description of change
/home/travis/build/sequelize/sequelize/lib/transaction.js 200:23 error Strings must use singlequote quotes /home/travis/build/sequelize/sequelize/test/integration/transaction.test.js 274:39 error Strings must use singlequote quotes 295:39 error Strings must use singlequote quotes 316:39 error Strings must use singlequote quotes ✖ 4 problems (4 errors, 0 warnings) 4 errors, 0 warnings potentially fixable with the `--fix` option.
Add `afterCommit` hooks for transactions that allows deferring work to after a transaction has been committed, regardless of if you have access to the promise chain that created the transaction Fixes: #2805
I think there is a bug in this feature: if transaction is a child (transaction.parent is set), then afterCommit hooks should not be invoked right after this transaction committed, because parent transaction is not committed yet, and is not guaranteed to be committed at all.
The easiest way to fix this is change the way how hooks are added: