Skip to content

fix: add ECMAScript Explicit Resource Management to Resource - #14103

Merged
Legend-Master merged 7 commits into
tauri-apps:devfrom
ddosakura:dev
Aug 17, 2026
Merged

fix: add ECMAScript Explicit Resource Management to Resource#14103
Legend-Master merged 7 commits into
tauri-apps:devfrom
ddosakura:dev

Conversation

@ddosakura

Copy link
Copy Markdown
Contributor

Add ECMAScript Explicit Resource Management to Resource.

This makes the await using work:

import { create, BaseDirectory } from "@tauri-apps/plugin-fs"
...
{
  await using file = await create("foo/bar.txt", { baseDir: BaseDirectory.AppConfig });
  await file.write(new TextEncoder().encode("Hello world"));
  // Before `file` goes out of scope, it is disposed by calling `file[Symbol.asyncDispose]()` and awaited.
}

@ddosakura
ddosakura requested a review from a team as a code owner August 28, 2025 03:58
@github-actions

github-actions Bot commented Aug 28, 2025

Copy link
Copy Markdown
Contributor

Package Changes Through 6dc9d1f

There are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-build with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-bundler with minor, tauri-macos-sign with minor, @tauri-apps/api with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.11.1 2.12.0
tauri-utils 2.9.3 2.10.0
tauri-macos-sign 2.3.4 2.4.0
tauri-bundler 2.9.4 2.10.0
tauri-runtime 2.11.3 2.12.0
tauri-runtime-wry 2.11.4 2.12.0
tauri-codegen 2.6.3 2.7.0
tauri-macros 2.6.3 2.7.0
tauri-plugin 2.6.3 2.7.0
tauri-build 2.6.3 2.7.0
tauri 2.11.5 2.12.0
@tauri-apps/cli 2.11.4 2.12.0
tauri-cli 2.11.4 2.12.0
tauri-driver 2.0.6 2.1.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master Legend-Master added this to the 2.9 milestone Aug 28, 2025
@Legend-Master

Copy link
Copy Markdown
Contributor

Thanks for bring this up!

I have one question though, I believe Symbol.asyncDispose doesn't exist on older browsers, should we provide a polyfill here?

Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management:~:text=Symbol.asyncDispose%20%3F%3F%3D%20Symbol(%22Symbol.asyncDispose%22)%3B

cc @lucasfernog @FabianLars

@FabianLars

Copy link
Copy Markdown
Member

Not only older browsers but webkit as a whole as well which means this is a Windows only change.

@Legend-Master

Legend-Master commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

but webkit as a whole

Technically it's a coming soon https://webkit.org/blog/16993/news-from-wwdc25-web-technology-coming-this-fall-in-safari-26-beta/ but yeah, this is still useful for people using the transpiler/polyfill themselves though

@FabianLars

Copy link
Copy Markdown
Member

hmm true but having macos 26 as a minimum version sounds a bit problematic (and who knows when/if linux follows)

@FabianLars FabianLars modified the milestones: 2.9, 2.10 Oct 15, 2025
@FabianLars FabianLars added the status: waiting Waiting on author label Jan 20, 2026
@Legend-Master Legend-Master modified the milestones: 2.11, 2.12 Apr 29, 2026

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and sorry for the long waits!

I think we should also looking into provide a guide on how to use this awesome feature! The symbol polyfill should not be needed in the tauri lib code, it stays undefined in unsupported browsers if you don't use using at all. If you do want to opt-in, use a compiler (e.g. tsc 5.2+)/bundler (e.g. rollup) that supports that syntax + defining

Symbol.dispose ??= Symbol("Symbol.dispose");
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");

to support old browsers.

@Legend-Master
Legend-Master merged commit be01979 into tauri-apps:dev Aug 17, 2026
18 checks passed
@Legend-Master Legend-Master removed the status: waiting Waiting on author label Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants