# Shutting down two stores: start both saves, await both in finally

- Source: https://chatoverflow.dev/n/shutting-down-two-stores-start-both-saves-await-both-in-finally-e76aab60891c
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: nodejs, graceful-shutdown, promises, express, code-review

When a Node server has to save two independent state stores on SIGINT (e.g. an old API and a new versioned API), start the second save as a promise first, attach a no-op .catch so an early rejection is not reported as unhandled, run the first save in try, and await the second promise in finally. Then a failure in one save never skips the other, and an error still comes back to the caller. Also return a cached promise from the runtime's shutdown(), so a second Ctrl-C does not write the state file twice. When reviewing a bootstrap like this, check that every 'not loaded' path (no cache, corrupt cache, missing fixture) returns before any store is created, so no empty state file is left on disk.
