1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 23:59:59 -05:00

fix(node): remove deprecation warnings (#22120)

Closes https://github.com/denoland/deno/issues/22116
This commit is contained in:
Bartek Iwańczuk 2024-01-26 00:36:03 +01:00 committed by GitHub
parent 0b0fb94ce2
commit 9951506506
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 9 deletions

View file

@ -81,7 +81,6 @@ async function runTest(t: Deno.TestContext, path: string): Promise<void> {
"run", "run",
"-A", "-A",
"--quiet", "--quiet",
"--unstable",
//"--unsafely-ignore-certificate-errors", //"--unsafely-ignore-certificate-errors",
"--unstable-bare-node-builtins", "--unstable-bare-node-builtins",
"--v8-flags=" + v8Flags.join(), "--v8-flags=" + v8Flags.join(),

View file

@ -655,12 +655,14 @@ function create(path) {
} }
class FsFile { class FsFile {
[SymbolFor("Deno.internal.rid")] = 0;
#rid = 0; #rid = 0;
#readable; #readable;
#writable; #writable;
constructor(rid, symbol) { constructor(rid, symbol) {
this[SymbolFor("Deno.internal.rid")] = rid;
this.#rid = rid; this.#rid = rid;
if (!symbol || symbol !== SymbolFor("Deno.internal.FsFile")) { if (!symbol || symbol !== SymbolFor("Deno.internal.FsFile")) {
internals.warnOnDeprecatedApi( internals.warnOnDeprecatedApi(

View file

@ -137,7 +137,7 @@ export function open(
path as string, path as string,
convertFlagAndModeToOptions(flags as openFlags, mode), convertFlagAndModeToOptions(flags as openFlags, mode),
).then( ).then(
(file) => callback!(null, file.rid), (file) => callback!(null, file[Symbol.for("Deno.internal.rid")]),
(err) => (callback as (err: Error) => void)(err), (err) => (callback as (err: Error) => void)(err),
); );
} }
@ -186,8 +186,10 @@ export function openSync(
throw new Error(`EEXIST: file already exists, open '${path}'`); throw new Error(`EEXIST: file already exists, open '${path}'`);
} }
return Deno.openSync(path as string, convertFlagAndModeToOptions(flags, mode)) return Deno.openSync(
.rid; path as string,
convertFlagAndModeToOptions(flags, mode),
)[Symbol.for("Deno.internal.rid")];
} }
function existenceCheckRequired(flags: openFlags | number) { function existenceCheckRequired(flags: openFlags | number) {

View file

@ -46,6 +46,8 @@ import {
} from "ext:deno_node/internal_binding/async_wrap.ts"; } from "ext:deno_node/internal_binding/async_wrap.ts";
import { codeMap } from "ext:deno_node/internal_binding/uv.ts"; import { codeMap } from "ext:deno_node/internal_binding/uv.ts";
const DENO_RID_SYMBOL = Symbol.for("Deno.internal.rid");
interface Reader { interface Reader {
read(p: Uint8Array): Promise<number | null>; read(p: Uint8Array): Promise<number | null>;
} }
@ -203,7 +205,7 @@ export class LibuvStreamWrap extends HandleWrap {
allBuffers: boolean, allBuffers: boolean,
): number { ): number {
const supportsWritev = this.provider === providerType.TCPSERVERWRAP; const supportsWritev = this.provider === providerType.TCPSERVERWRAP;
const rid = this[kStreamBaseField]!.rid; const rid = this[kStreamBaseField]![DENO_RID_SYMBOL];
// Fast case optimization: two chunks, and all buffers. // Fast case optimization: two chunks, and all buffers.
if ( if (
chunks.length === 2 && allBuffers && supportsWritev && chunks.length === 2 && allBuffers && supportsWritev &&
@ -317,13 +319,15 @@ export class LibuvStreamWrap extends HandleWrap {
async #read() { async #read() {
let buf = this.#buf; let buf = this.#buf;
let nread: number | null; let nread: number | null;
const ridBefore = this[kStreamBaseField]!.rid; const ridBefore = this[kStreamBaseField]![DENO_RID_SYMBOL];
try { try {
nread = await this[kStreamBaseField]!.read(buf); nread = await this[kStreamBaseField]!.read(buf);
} catch (e) { } catch (e) {
// Try to read again if the underlying stream resource // Try to read again if the underlying stream resource
// changed. This can happen during TLS upgrades (eg. STARTTLS) // changed. This can happen during TLS upgrades (eg. STARTTLS)
if (ridBefore != this[kStreamBaseField]!.rid) { if (
ridBefore != this[kStreamBaseField]![DENO_RID_SYMBOL]
) {
return this.#read(); return this.#read();
} }
@ -373,7 +377,7 @@ export class LibuvStreamWrap extends HandleWrap {
async #write(req: WriteWrap<LibuvStreamWrap>, data: Uint8Array) { async #write(req: WriteWrap<LibuvStreamWrap>, data: Uint8Array) {
const { byteLength } = data; const { byteLength } = data;
const ridBefore = this[kStreamBaseField]!.rid; const ridBefore = this[kStreamBaseField]![DENO_RID_SYMBOL];
let nwritten = 0; let nwritten = 0;
try { try {
@ -386,7 +390,9 @@ export class LibuvStreamWrap extends HandleWrap {
} catch (e) { } catch (e) {
// Try to read again if the underlying stream resource // Try to read again if the underlying stream resource
// changed. This can happen during TLS upgrades (eg. STARTTLS) // changed. This can happen during TLS upgrades (eg. STARTTLS)
if (ridBefore != this[kStreamBaseField]!.rid) { if (
ridBefore != this[kStreamBaseField]![DENO_RID_SYMBOL]
) {
return this.#write(req, data.subarray(nwritten)); return this.#write(req, data.subarray(nwritten));
} }