Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Concurrency, Failures and Cancellation in Async Code (Summary)

You’ve finished Concurrency, Failures and Cancellation in Async Code.

In This Course, You Learned How To

  • Start async work together, and report which jobs worked
  • Run async work one at a time or all together, on purpose
  • Handle failures so none goes unheard
  • Give up on slow work with timeouts and cancellation
  • Find and fix race conditions
  • Build the Lindqvists’ morning routine

The Lindqvists’ Morning, Step by Step

Await one device at a time, and the morning took twelve seconds. Start them all, then wait, and it took six.

When the blinds failed, Promise.all() rejected at two seconds, but the others still finished. Promise.allSettled() waited for all four and reported which worked.

A rejection nobody owns stops Node. So every promise got an owner, and you caught its error where you could respond.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 You’ve finished Concurrency, Failures and Cancellation in Async Code. In this course, you learned how to: Start async work together, and report which jobs worked.

00:12 Run async work one at a time, or all together, on purpose. Handle failures so none goes unheard. Give up on slow work with timeouts and cancellation. Find and fix race conditions.

00:25 And build the Lindqvists’ morning routine.

00:30 Await one device at a time, and the morning took twelve seconds. Start them all, then wait, and it took six. When the blinds failed, Promise.all() rejected at two seconds, but the others still finished.

00:44 Promise.allSettled() waited for all four and reported which worked. A rejection nobody owns stops Node. So every promise got an owner, and you caught its error where you could respond.

00:58 The kettle’s timer got a deadline signal, and it stopped at five seconds. Snooze worked the same way. A signal stops only work that checks it, or passes it on.

01:09 Other work gets a turn only while your code pauses at an await, or once it finishes. Saga’s tap slipped into that pause and ran the routine twice, until you claimed the morning before waiting.

01:23 Yesterday’s late reply overwrote today’s status, until each run checked its number after the wait.

01:31 Calling a function starts its work. An await only waits for it. Sequence only the steps that need an earlier result. Give every promise an owner, and catch where you can respond.

01:43 No combinator stops work. A signal stops only work that checks it or passes it on. Claim shared state before an await, and check it after.

01:55 Your devices were stand-ins with fixed delays. Real requests over the network come next. Revisit Promise in the RealJS reference, and the event loop in its glossary.

02:09 Thanks for watching.

Become a Member to join the conversation.