2023 주니어 SRE 엔지니어 후레임

반응형

시퀄라이즈(Sequelize) 트랜젝션 사용 도중
Cannot read property 'uuid' of undefined라는 알 수 없는 에러가 뜨며 실행불가.

Cannot read property 'uuid' of undefined

 

uuid? 내가 선언한 적도 없는 변수였다.
구글링을 해보니, 깃헙에 해결책이 있었다!

github.com/sequelize/sequelize/issues/8125

Just wanted to add that this often happens to me when I forget to await the transaction.

// Causes error:
const transaction = sequelize.transaction()
await User.findByPk(1, {transaction})

// Doesn't cause error: 
const transaction = await sequelize.transaction()
await User.findByPk(1, {transaction})

sequelize.transaction() 앞에 await만 추가해주면 되는 간단한 문제였다.

반응형

이 글을 공유합시다

facebook twitter googleplus kakaoTalk kakaostory naver band