728x90
Situation
- Frontend team reported 500 error on production server which is internal server-related error
Cause
- the property deconstruction error
- It is caused because code tried to deconstruct
undefined
property.
{
"statusCode": 500,
"status": "TypeError",
"message": "Cannot destructure property 'appName' of 'appDict.get(...)' as it is undefined."
}
async getUser(getUserDto: GetUserDto): Promise<object> {
...
const { appName, platform }: Partial<queryData> = appDict.get(app['appId']);
...
Solution
// adding if condition before accessing
if (appDict.get(app['appId'])) {
- Put
if
statement to make sure it is notundefined
- If is undefined, deconstructing assignment will not be proceeded and there will be no error
Today I learn
Consider variables when it is undefined
- Whenver I handle variables, I should consider possibilities of variables containing
undefined
. Before some jobs dealing with variables such as deconstructing assignment, make sure the variable contain the expected value
Dive as soon as possible when production down
- As soon as error occurs on production server, our engineering team dive into this problem to fix right away. It was my issues but team tried solving one problem together to reduce downtime of production server
728x90
'Log > Trouble shoot' 카테고리의 다른 글
node.js_복잡한 형식의 private_key를 .env 환경변수로 사용하는 방법 (0) | 2023.08.01 |
---|---|
Docker-mysql-access denied for user...(using password YES) (0) | 2023.06.07 |
nestjs_ ERROR [ExceptionHandler] Nest can't resolve dependencies (0) | 2023.06.07 |
shootingstar_Error_chmod 권한 문제로 파일 저장 불가 문제 (0) | 2023.04.16 |
shootingstar_실패로그_EC2에 Selenium scraping flask server 띄우기 (0) | 2023.04.14 |
댓글