Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: remove Deno.close() #25347

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2265,33 +2265,6 @@ declare namespace Deno {
*/
export function fdatasyncSync(rid: number): void;

/** Close the given resource ID (`rid`) which has been previously opened, such
* as via opening or creating a file. Closing a file when you are finished
* with it is important to avoid leaking resources.
*
* ```ts
* const file = await Deno.open("my_file.txt");
* // do work with "file" object
* Deno.close(file.rid);
* ```
*
* It is recommended to define the variable with the `using` keyword so the
* runtime will automatically close the resource when it goes out of scope.
* Doing so negates the need to manually close the resource.
*
* ```ts
* using file = await Deno.open("my_file.txt");
* // do work with "file" object
* ```
*
* @deprecated This will be removed in Deno 2.0. See the
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
* for migration instructions.
*
* @category I/O
*/
export function close(rid: number): void;

/** The Deno abstraction for reading and writing files.
*
* This is the most straight forward way of handling files within Deno and is
Expand Down
10 changes: 0 additions & 10 deletions runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,6 @@ const internalSymbol = Symbol("Deno.internal");
const finalDenoNs = {
internal: internalSymbol,
[internalSymbol]: internals,
close(rid) {
internals.warnOnDeprecatedApi(
"Deno.close()",
new Error().stack,
"Use `closer.close()` instead.",
);
core.close(rid);
},
...denoNs,
// Deno.test and Deno.bench are noops here, but kept for compatibility; so
// that they don't cause errors when used outside of `deno test`/`deno bench`
Expand Down Expand Up @@ -928,7 +920,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
if (future) {
delete globalThis.window;
delete Deno.Buffer;
delete Deno.close;
delete Deno.copy;
delete Deno.File;
delete Deno.fstat;
Expand Down Expand Up @@ -1115,7 +1106,6 @@ function bootstrapWorkerRuntime(

if (future) {
delete Deno.Buffer;
delete Deno.close;
delete Deno.copy;
delete Deno.File;
delete Deno.fstat;
Expand Down
1 change: 0 additions & 1 deletion tests/integration/js_unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ util::unit_test_factory!(
remove_test,
rename_test,
request_test,
resources_test,
response_test,
serve_test,
signal_test,
Expand Down
1 change: 0 additions & 1 deletion tests/specs/future/runtime_api/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
console.log("window is", globalThis.window);
console.log("Deno.Buffer is", Deno.Buffer);
console.log("Deno.close is", Deno.close);
console.log("Deno.copy is", Deno.copy);
console.log("Deno.File is", Deno.File);
console.log("Deno.fstat is", Deno.fstat);
Expand Down
1 change: 0 additions & 1 deletion tests/specs/future/runtime_api/main.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
window is undefined
Deno.Buffer is undefined
Deno.close is undefined
Deno.copy is undefined
Deno.File is undefined
Deno.fstat is undefined
Expand Down
11 changes: 0 additions & 11 deletions tests/unit/resources_test.ts

This file was deleted.