From 190d0e304c37e617f3be37c574f3f41b98b0a8a6 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 2 Sep 2024 12:01:10 +1000 Subject: [PATCH 1/2] chore: remove `Deno.close()` --- cli/tsc/dts/lib.deno.ns.d.ts | 27 ------------------------- runtime/js/99_main.js | 10 --------- tests/specs/future/runtime_api/main.js | 1 - tests/specs/future/runtime_api/main.out | 1 - 4 files changed, 39 deletions(-) diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 7a0146bf02df11..23fcca492aea8b 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -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 diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 578bde6684c4c8..bfb3fa795c4e79 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -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` @@ -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; @@ -1115,7 +1106,6 @@ function bootstrapWorkerRuntime( if (future) { delete Deno.Buffer; - delete Deno.close; delete Deno.copy; delete Deno.File; delete Deno.fstat; diff --git a/tests/specs/future/runtime_api/main.js b/tests/specs/future/runtime_api/main.js index 6bc83d30c545f9..503b6e5fbd0b9d 100644 --- a/tests/specs/future/runtime_api/main.js +++ b/tests/specs/future/runtime_api/main.js @@ -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); diff --git a/tests/specs/future/runtime_api/main.out b/tests/specs/future/runtime_api/main.out index 2a8167ef9a2512..eca1c3741f7c97 100644 --- a/tests/specs/future/runtime_api/main.out +++ b/tests/specs/future/runtime_api/main.out @@ -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 From a2f463318baa6339f4c1783c1e113fba9b98de5e Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 2 Sep 2024 12:17:45 +1000 Subject: [PATCH 2/2] fix --- tests/integration/js_unit_tests.rs | 1 - tests/unit/resources_test.ts | 11 ----------- 2 files changed, 12 deletions(-) delete mode 100644 tests/unit/resources_test.ts diff --git a/tests/integration/js_unit_tests.rs b/tests/integration/js_unit_tests.rs index cbae4a0b8c4518..9c4ac0e528381d 100644 --- a/tests/integration/js_unit_tests.rs +++ b/tests/integration/js_unit_tests.rs @@ -78,7 +78,6 @@ util::unit_test_factory!( remove_test, rename_test, request_test, - resources_test, response_test, serve_test, signal_test, diff --git a/tests/unit/resources_test.ts b/tests/unit/resources_test.ts deleted file mode 100644 index 3c692a1a446660..00000000000000 --- a/tests/unit/resources_test.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-deprecated-deno-api - -import { assertThrows } from "./test_util.ts"; - -Deno.test(function resourcesCloseBadArgs() { - assertThrows(() => { - Deno.close((null as unknown) as number); - }, TypeError); -});