프라미스 체인을 사용하면 모든 단계에서 에러를 캐치할 필요는 없습니다. 체인 어디에서든 에
러가 생기면 체인 전체가 멈추고
catch
핸들러가 동작합니다. 카운트다운을
15
초로 바꾸고 미
신을 넣어서 실행해 보십시오.
launch
는 실행되지 않습니다.
14.3.5
결정되지 않는 프라미스 방지하기
프라미스는 비동기적 코드를 단순화하고 콜백이 두 번 이상 실행되는 문제를 방지합니다. 하지
만
resolve
나
reject
를 호출하는 걸 잊어서 프라미스가 결정되지 않는 문제까지 자동으로 해
결하지는 못합니다. 에러가 일어나지 않으므로 이런 실수는 찾기 매우 어렵습니다. 복잡한 시
스템에서 결정되지 않은 프라미스는 그냥 잊혀질 수 있습니다.
결정되지 않은 프라미스를 방지하는 한 가지 방법은 프라미스에 타임아웃을 거는 겁니다. 충분
한 시간이 지났는데도 프라미스가 결정되지 않으면 자동으로 실패하게 만들 수 있습니다. 물론
얼마나 기다려야 ‘충분히’ 기다렸는지는 스스로 판단해야 합니다.
10
분 정도는 걸릴 거로 생각
하는 복잡한 알고리즘에 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.