79566493

Date: 2025-04-10 11:26:22
Score: 0.5
Natty:
Report link

I found the issue,

    let instituteUser = await this.instituteUsersRepository.findOneBy({id: 1});
    instituteUser.updated_at = new Date().toISOString()

    await this.instituteUsersRepository.save(instituteUser) // Works OK
    await this.instituteUsersRepository.update({ id: 1 }, { updated_at: new Date().toISOString() }); // Works OK
    await instituteUser.save(); // Throws Error

The issue does not happen consistently. Sometimes, when I start the app, entity.save() works fine. Other times, it fails with the read-only transaction error.

This makes me suspect it depends on: Order of connection initialization or which connection is resolved at runtime

Anyway, solved it by changing the save function.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Niv Lusty