Your routine can now start devices one at a time, all together, or a few at a time, and it waits for every device it starts. In Wait for Every Device to Finish, you also saw what happens when nothing holds a device’s promise. The blinds failed, no part of your code heard it, and Node.js stopped the whole program.
That lesson left open what Node.js does with a failure like that. In this lesson, you’ll trace where a device’s rejection ends up, read what Node.js prints when nobody is listening, and make sure every device call has code that hears how it went.
Start a Device Nobody Waits for
In this section, you’ll run a routine that starts a device without await, knowing it fails, so you can see where the blinds’ error ends up and what Node.js does with it.
The blinds are offline again this morning. In your morning folder, make sure devices.mjs is the version where openBlinds() throws after two seconds:
devices.mjs
import { setTimeout as delay } from "node:timers/promises";
export async function turnOnLights() {
await delay(1000);
return "Lights on";
}
export async function openBlinds() {
await delay(2000);
throw new Error("Blinds offline");
}
export async function warmUpHeating() {
await delay(3000);
return "Heating on";
}
export async function boilKettle() {
await delay(6000);
return "Kettle boiled";
}
Now save this routine as good_morning.mjs. Erik’s greeting only mentions the lights, so the goodMorning() function starts the blinds without await, awaits the lights, and returns the greeting:
good_morning.mjs
import { turnOnLights, openBlinds } from "./devices.mjs";
async function goodMorning() {
openBlinds();
const lights = await turnOnLights();
return `Good morning! ${lights}`;
}
console.log(await goodMorning());
console.log("Routine finished");
Watch out: calling an async function without await because you don’t need its result doesn’t make its failures go away. They still happen, later, with nobody listening.
Run it, and then type echo $? to see the number the program ended with. The first two lines appear after one second, and the error a second later:
$ node good_morning.mjs
Good morning! Lights on
Routine finished
file:///Users/you/morning/devices.mjs:10
throw new Error("Blinds offline");
^
Error: Blinds offline
at openBlinds (file:///Users/you/morning/devices.mjs:10:9)
Node.js v26.13.1
$ echo $?
1
Your path will differ from /Users/you/morning. In PowerShell on Windows, type $LASTEXITCODE instead of echo $? to see the same 1.
Read the output in the order it arrived. The routine said good morning and announced that it had finished. A second later, the blinds failed and took the program down. Node.js was still running only because the blinds’ timer hadn’t fired yet, the same reason Saga’s ready check kept the prompt waiting for the kettle.
The goodMorning() function dropped the promise that openBlinds() returned. A promise that no code awaits, returns, or attaches a handler to is a floating promise. It still settles, but nothing in your code will ever hear how.