# Untangling Deeply-Nested Promise Chains

DevFeed: [Untangling Deeply-Nested Promise Chains](<https://devfeed.tech/articles/untangling-deeply-nested-promise-chains-29531.md>)

Original publisher: [Read original article](<https://philipwalton.com/articles/untangling-deeply-nested-promise-chains/>)

Published: 2016-08-17T14:53:31Z

Content type: article

Language: en

Sources: [Philip Walton](<https://devfeed.tech/sources/philip-walton.md>)

Topics: [Promise](<https://devfeed.tech/topics/promise.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Refactoring](<https://devfeed.tech/topics/refactoring.md>), [Web APIs](<https://devfeed.tech/topics/web-apis.md>), [async](<https://devfeed.tech/topics/async.md>), [Caching](<https://devfeed.tech/topics/caching.md>)

Tags: [async](<https://devfeed.tech/tags/async.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [cache](<https://devfeed.tech/tags/cache.md>), [caching](<https://devfeed.tech/tags/caching.md>), [callback](<https://devfeed.tech/tags/callback.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>), [tutorials](<https://devfeed.tech/tags/tutorials.md>)

## AI overview

The article examines how promise-based Service Worker code can become deeply nested and difficult to understand, despite promises being intended to improve on callback-heavy code. It discusses a network-first strategy with cache fallback for offline support and presents refactoring strategies, software development practices, and async functions to improve readability and maintainability.

## Source excerpt

If you've been writing JavaScript for a while, you've probably heard terms like callback hell or the pyramid of doom. When promises were added to JavaScript a few years ago, I remember reading a lot of blog posts claiming that these problems would be solved; unfortunately, that was a little too optimistic. With more and more web APIs becoming promise-based, we've proven that even promises don't prevent us from writing overly-nested, hard-to-read code.