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 9–Nov 16 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/16/2026, 12:01:57 AM 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

2 sources
There is no reason why you could not, in principle, have Rust-style compile-time borrow checking in a managed language. As an extreme example (that I have occasionally thought about doing though probably won't), you could fork TypeScript and add ownership and lifetime and inherited-mutability annotations to it, and have the compiler enforce single-ownership and shared-xor-mutable except in code that has specifically opted out of this. As with existing features of TypeScript's type system, this wouldn't affect the emitted code at all—heap allocations would still be freed nondeterministically by the tracing GC at runtime, not necessarily at the particular point in the program where they stop being used—but you'd get the maintainability benefits of not allowing unrestricted aliasing. (Since you wouldn't have destructors, you might need to us
Read the rest
e linear instead of affine types, to ensure that programmers can't forget to call a resource object's cleanup method when they're done with it. Alternatively, you could require https://github.com/tc39/proposal-explicit-resource-managemen... to be used, once that gets added to JavaScript.) Of course, if you design a runtime specifically to be targeted by such a language, more becomes possible. See https://without.boats/blog/revisiting-a-smaller-rust/ for one sketch of what this might look like.
In Why Is C Faster Than Java (2009)

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.