1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

FUTURE: remove deprecated APIs within workers (#23220)

This commit is contained in:
Asher Gomez 2024-04-05 03:27:18 +11:00 committed by GitHub
parent 945eb5eba6
commit 207349cfb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 56 additions and 7 deletions

View file

@ -813,7 +813,7 @@ fn create_web_worker_callback(
node_ipc_fd: None,
disable_deprecated_api_warning: shared.disable_deprecated_api_warning,
verbose_deprecated_api_warning: shared.verbose_deprecated_api_warning,
future: false,
future: shared.enable_future_features,
},
extensions: vec![],
startup_snapshot: crate::js::deno_isolate_init(),

View file

@ -837,7 +837,7 @@ function bootstrapWorkerRuntime(
6: argv0,
7: shouldDisableDeprecatedApiWarning,
8: shouldUseVerboseDeprecatedApiWarning,
9: _future,
9: future,
} = runtimeOptions;
deprecatedApiWarningDisabled = shouldDisableDeprecatedApiWarning;
@ -937,6 +937,37 @@ function bootstrapWorkerRuntime(
workerMetadata,
);
}
if (future) {
delete Deno.Buffer;
delete Deno.close;
delete Deno.copy;
delete Deno.File;
delete Deno.fstat;
delete Deno.fstatSync;
delete Deno.ftruncate;
delete Deno.ftruncateSync;
delete Deno.flock;
delete Deno.flockSync;
delete Deno.FsFile.prototype.rid;
delete Deno.funlock;
delete Deno.funlockSync;
delete Deno.iter;
delete Deno.iterSync;
delete Deno.metrics;
delete Deno.readAll;
delete Deno.readAllSync;
delete Deno.read;
delete Deno.readSync;
delete Deno.resources;
delete Deno.seek;
delete Deno.seekSync;
delete Deno.shutdown;
delete Deno.writeAll;
delete Deno.writeAllSync;
delete Deno.write;
delete Deno.writeSync;
}
} else {
// Warmup
return;

View file

@ -1,7 +1,18 @@
{
"args": "run -A main.js",
"output": "main.out",
"envs": {
"DENO_FUTURE": "1"
}
"steps": [
{
"args": "run -A --unstable-fs main.js",
"output": "main.out",
"envs": {
"DENO_FUTURE": "1"
}
},
{
"args": "run -A --unstable-fs worker.js",
"output": "main.out",
"envs": {
"DENO_FUTURE": "1"
}
}
]
}

View file

@ -30,3 +30,5 @@ console.log("Deno.writeAll is", Deno.writeAll);
console.log("Deno.writeAllSync is", Deno.writeAllSync);
console.log("Deno.write is", Deno.write);
console.log("Deno.writeSync is", Deno.writeSync);
self.close();

View file

@ -0,0 +1,5 @@
import { delay } from "../../../util/std/async/delay.ts";
const worker = new Worker(import.meta.resolve("./main.js"), { type: "module" });
await delay(1_000);
worker.terminate();