Skip to content

Commit c71272a

Browse files
authored
add service worker use case (#127)
1 parent ff47c28 commit c71272a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

USE-CASES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,11 @@ new PerformanceObserver(list => {
340340
Read more at [opentelemetry/fetch](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch).
341341

342342
[OpenTelemetry]: https://github.com/open-telemetry/opentelemetry-js
343+
344+
## Use Case: Running servers in service workers
345+
346+
A typical web app has a server-side component and a client-side component. Many web frameworks (Next, Nuxt, SvelteKit etc) are designed in such a way that both halves can be built from a single codebase.
347+
348+
One request that framework maintainers often receive is for the ability to run the server, or at least part of it, in a service worker. Barring any dependencies on sensitive information that should not be accessible to users, or packages that only run in a server environment, this can be a successful strategy for building low-latency apps that are resilient in the face of poor network conditions.
349+
350+
Many of these frameworks, however, have embraced `AsyncLocalStorage` within their server code, since it unlocks a plethora of use cases and is well supported by various server environments. The lack of an equivalent API _outside_ server environments is thus preventing frameworks from embracing service workers.

0 commit comments

Comments
 (0)