Urgent.News

What's breaking now, across thousands of outlets.

Tech

Why should request state survive after the request is finished?

Evidence box — every Usai post states the limits of its claims. Status: Usai v0.0.10, alpha. Production qualification is in progress; contracts may still change. The sweep was measured on 0.0.8. Supports: a fresh execution world per unit of work (a module-level counter answers 1 on every request); on routes that touch PostgreSQL, throughput level with a single Node process and ahead of it on…

In most server environments, a request creates mutable application state that persists beyond the life of the request itself. This happens because the process that handles the request continues to run, carrying the state with it. This approach is efficient and familiar, but it means that state's lifetime is determined by where it resides, not by its purpose.

Usai aims to separate these two aspects. The issue is that many variables and objects created during a request continue to exist even after the request has finished, leading to unexpected behavior and potential bugs. While it's true that platforms like AWS Lambda and Cloudflare Workers reuse execution environments for speed, they advise against storing potentially sensitive data in the execution environment.

Usai takes a different approach, proposing that the distinction between persistent infrastructure and application state should be enforced at the runtime level. In Usai, the application is divided into three layers, each with its own lifetime: the persistent runtime, which runs throughout the process; immutable application definition, built once per deploy; and the execution world, which exists for the duration of one unit of work, such as a request, task, or timer.

Each request or task gets a fresh execution world, ensuring that state is ephemeral by default. While there are cases where some data should persist, like database connections or WebSocket connections, these are declared as persistent on purpose. Usai's runtime cancels any asynchronous work that outlives its execution world, preventing potential issues that could arise from lingering state.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Don't Enqueue What You Cannot Reserve

A free lane is the wrong bet when you cannot reserve the attempt before anything admits it. A zero price does not make the prompt free of time, and a client timeout does not hand the tokens back.

Indie makers build Productivity apps. The visits go to Food & Drink and Finance.

There are two easy ways to count an indie app category: how many apps are in it, and how much attention those apps actually get. I assumed they would roughly line up.

  • Productivity apps have 31 apps, ranking sixth in visits with 89
  • Food & Drink and Finance categories receive most visits (331 and 320)
  • Health & Fitness leads in both number of apps (41) and visits

More from Thursday 24 September →