HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
tc39
proposal-explicit-resource-management
JavaScript2021–2025
tc39 / proposal-explicit-resource-management

proposal-explicit-resource-management

ECMAScript Explicit Resource Management

29Distinct people
31Mentions
0Explicit recommenders
940GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

ECMAScript Explicit Resource Management

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year31 dated mentions

Observed mentions: 2021-12-13 12:59:33 UTC to 2025-09-08 17:13:55 UTC.

0510152021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 15 mentions; 2 submissions, 13 comments20232024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 10 mentions; 0 submissions, 10 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC202
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC15213
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC303
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC10010

From the project README

An excerpt from the repository, fetched Nov 12, 2026.

Read the project’s introduction
ECMAScript Explicit Resource Management NOTE: This proposal has subsumed the Async Explicit Resource Management proposal. This proposal repository should be used for further discussion of both sync and async of explicit resource management. This proposal intends to address a common pattern in software development regarding the lifetime and management of various resources (memory, I/O, etc.). This pattern generally includes the allocation of a resource and the ability to explicitly release critical resources. For example, ECMAScript Generator Functions and Async Generator Functions expose this pattern through the return method, as a means to explicitly evaluate finally blocks to ensure user-defined cleanup logic is preserved: // sync generators function * g() { const handle = acquireFileHandle(); // critical resource try { ... } finally { handle.release(); // cleanup } } const obj = g(); try { const r = obj.next(); ... } finally { obj.return(); // calls finally blocks in `g` } // async generators async function * g() { const handle = acquireStream(); // critical resource try { ... } finally { await stream.close(); // cleanup } } const obj = g(); try { const r = await obj.next(); ... } finally { await obj.return(); // calls finally blocks in `g` } As such, we propose the adoption of a novel syntax to simplify this common pattern: // sync disposal function * g() { using handle = acquireFileHandle(); // block-scoped critical resource } // cleanup { using obj = g(); // block-scoped declaration const r = obj.next(); } // calls finally blocks in `g` // async disposal async function * g() { using stream = acquireStream(); // block-scoped critical resource ... } // cleanup { await using obj = g(); // block-scoped declaration const r = await obj.next(); } // calls finally blocks in `g` In addition, we propose the addition of two disposable container objects to assist with managing multiple resources: DisposableStack — A stack-based container of disposable resources. AsyncDisposableStack — A stack-based container of asynchronously disposable resources. Status Stage: 3 Champion: Ron Buckton (@rbuckton) Last Presented: March, 2023 (slides, notes #1, notes #2) For more information see the TC39 proposal process. Authors Ron Buckton (@rbuckton) Motivations This proposal is motivated by a number of cases: Inconsistent patterns for resource management: ECMAScript Iterators: iterator.return() WHATWG Stream Readers: reader.releaseLock() NodeJS FileHandles: handle.close() Emscripten C++ objects handles: Module._free(ptr) obj.delete() Module.destroy(obj) Avoiding common footguns when managing resources: const reader = stream.getReader(); ... reader.releaseLock(); // Oops, should have been in a try/finally Scoping resources: const handle = ...; try { ... // ok to use `handle` } finally { handle.close(); } // not ok to use `handle`, but still in scope Avoiding common footguns when managing multiple resources: const a = ...; const b = ...; try { ... } finally { a.close(); // Oops, issue if `b.close()` depends on `a`. b.close(); // Oops, `b` never reached if `a.close()` throws. } Avoiding lengthy code when managing multiple resources correctly: // sync disposal { // block avoids leaking `a` or `b` to outer scope const a = ...; try { const b = ...; try { ... } finally { b.close(); // ensure `b` is closed before `a` in case `b` // depends on `a` } } finally { a.close(); // ensure `a` is closed even if `b.close()` throws } } // both `a` and `b` are out of scope Compared to: // avoids leaking `a` or `b` to outer scope // ensures `b` is disposed before `a` in case `b` depends on `a` // ensures `a` is disposed even if disposing `b` throws using a = ..., b = ...; ... // async sync disposal { // block avoids leaking `a` or `b` to outer scope const a = ...; try { const b = ...; try { ... } finally { await b.close(); // ensure `b` is closed before `a` in case `b` // depends on `a` } } finally { await a.close(); // ensure `a` is closed even if `b.close()` throws } } // both `a` and `b` are out of scope Compared to: // avoids leaking `a` or `b` to outer scope // ensures `b` is disposed before `a` in case `b` depends on `a` // ensures `a` is disposed even if disposing `b` throws await using a = ..., b = ...; ... Non-blocking memory/IO applications: import { ReaderWriterLock } from "..."; const lock = new ReaderWriterLock(); export async function readData() { // wait for outstanding writer and take a read lock using lockHandle = await lock.read(); ... // any number of readers await ...; ... // still in read lock after `await` } // release the read lock export async function writeData(data) { // wait for all readers and take a write lock using lockHandle = await lock.write(); ... // only one writer await ...; ... // still in write lock after `await` } // release the write lock Potential for use with the Fixed Layout Objects Proposal and shared struct: // main.js shared struct class SharedData { ready = false; processed = false; } const worker = new Worker('worker.js'); const m = new Atomics.Mutex(); const cv = new Atomics.ConditionVariable(); const data = new SharedData(); worker.postMessage({ m, cv, data }); // send data to worker { // wait until main can get a lock on 'm' using lck = m.lock(); // mark data for worker data.ready = true; console.log("main is ready"); } // unlocks 'm' // notify potentially waiting worker cv.notifyOne(); { // reacquire lock on 'm' using lck = m.lock(); // release the lock on 'm' and wait for the worker to finish processing cv.wait(m, () => data.processed); } // unlocks 'm' // worker.js onmessage = function (e) { const { m, cv, data } = e.data; { // wait until worker can get a lock on 'm' using lck = m.
Read the full README on GitHub

What Hacker News says

31 sources
> This looks most similar to golang’s defer. It runs cleanup code when leaving the current scope. It's nothing like go's defer: Go's defer is function-scoped and registers a callback, using is block-scoped and registers an object with a well defined protocol. > It differs from [...] c# “using,” It's pretty much a direct copy of C#'s `using` declaration (as opposed to the using statement): https://learn.microsoft.com/en-us/dotnet/csharp/language-ref.... This can also be seen from the proposal itself (https://github.com/tc39/proposal-explicit-resource-managemen...) which cites C#'s using statement and declaration, Java's try-with-resource, and Python's context managers as prior art, but only mentions Go's defer as something you can emulate via DisposableStack and AsyncDisposableStack (types which are specifically inspired by Python's ExitSt
Read the rest
ack),
In JavaScript's New Superpower: Explicit Resource Management
Here’s some relevant discussion about some of the footguns: https://github.com/typescript-eslint/typescript-eslint/issue... https://github.com/tc39/proposal-explicit-resource-managemen... I imagine there will eventually be lint rules for this somewhere and many of those using such a modern feature are likely to be using static analysis via eslint to help mitigate the risks here, but until it’s more established and understood and lint rules are fleshed out and widely adopted, there is risk here for sure. https://github.com/typescript-eslint/typescript-eslint/issue... To me it seems a bit like popular lint libraries just going ahead and adding the rule would make a big difference here
In JavaScript's New Superpower: Explicit Resource Management
In addition to this, is the new (stage 3 even!)explicit resource management proposal[0], supported by TypeScript version >= 5.2[1] Though I agree that async context is better fit for this generally, the ERM should be good for telemetry around objects that have defined lifetime semantics, which is a step in the right direction you can use today [0]: https://github.com/tc39/proposal-explicit-resource-managemen... [1]: https://www.totaltypescript.com/typescript-5-2-new-keyword-u...
In OpenTelemetry in 2023

Showing the 15 most recent of 31 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.