Skip to content

Conversation

iNishant
Copy link

@iNishant iNishant commented Mar 25, 2025

Adds support for awaiting async callbacks in on-commit hooks

for eg in below code

class UserService {
    async enqueueSignUpEmail(user) {
      await queue.publish(....);
    }
  
    @Transactional
    async createUser(user) {
       const newUser = await this.repo.insert(user);

      // Some more business logic
 
      // No way to `await` the side effect earlier
      runOnTransactionCommit(() => this.enqueueSignUpEmail(user));

     // Some more business logic

    }
}

const newUser = await new UserService().createUser(...)
// At this point side-effects have been awaited as well

@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