Skip to content

Conversation

@iNishant
Copy link

@iNishant iNishant commented Mar 25, 2025

Adds support for awaiting async callbacks in on-commit hooks

class UserService {
    async enqueueSignUpEmail(user) {
      await queue.publish(....);
    }
  
    @Transactional
    async createUser(user) {
       const newUser = await this.repo.insert(user);
 
       // Earlier this async side-effect enqueueSignUpEmail was not
       // awaited at any point.
       // Now with the change in this branch, this side-effect is
       // awaited right after commit.

       runOnTransactionCommit(() => this.enqueueSignUpEmail(user));

    }
}

@Aliheym thoughts on this?

@iNishant iNishant marked this pull request as draft March 25, 2025 17:20
@iNishant iNishant marked this pull request as ready for review March 25, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant