From 357bcfcf79fee92195e37bb3f05e247908f207c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 27 Mar 2023 16:25:17 +0200 Subject: =?UTF-8?q?Revert=20"refactor:=20remove=20Deno[Deno.internal].node?= =?UTF-8?q?Unstable=20namespace=20(=E2=80=A6=20(#18458)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …#18449)" This reverts commit d1a9c4cd7ce0c19ddf9c7c52c0d35d6124a7677d. Appears this made CI very flaky on macOS, but I can't repeat it locally yet --- runtime/js/90_deno_ns.js | 6 +---- runtime/js/99_main.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) (limited to 'runtime/js') diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index cada4615e..54480c9c7 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -153,10 +153,7 @@ const denoNs = { }; const denoNsUnstable = { - listenDatagram: net.createListenDatagram( - ops.op_net_listen_udp, - ops.op_net_listen_unixpacket, - ), + listenDatagram: net.listenDatagram, umask: fs.umask, HttpClient: httpClient.HttpClient, createHttpClient: httpClient.createHttpClient, @@ -173,7 +170,6 @@ const denoNsUnstable = { funlockSync: fs.funlockSync, upgradeHttp: http.upgradeHttp, upgradeHttpRaw: flash.upgradeHttpRaw, - serve: flash.createServe(ops.op_flash_serve), openKv: kv.openKv, Kv: kv.Kv, KvU64: kv.KvU64, diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index bc67a5897..d043f485e 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -45,6 +45,7 @@ import * as version from "ext:runtime/01_version.ts"; import * as os from "ext:runtime/30_os.js"; import * as timers from "ext:deno_web/02_timers.js"; import * as colors from "ext:deno_console/01_colors.js"; +import * as net from "ext:deno_net/01_net.js"; import { inspectArgs, quoteString, @@ -58,6 +59,7 @@ import { denoNs, denoNsUnstable } from "ext:runtime/90_deno_ns.js"; import { errors } from "ext:runtime/01_errors.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; +import * as flash from "ext:deno_flash/01_http.js"; import { mainRuntimeGlobalProperties, setLanguage, @@ -453,6 +455,27 @@ function bootstrapMainRuntime(runtimeOptions) { setUserAgent(runtimeOptions.userAgent); setLanguage(runtimeOptions.locale); + // These have to initialized here and not in `90_deno_ns.js` because + // the op function that needs to be passed will be invalidated by creating + // a snapshot + ObjectAssign(internals, { + nodeUnstable: { + serve: flash.createServe(ops.op_node_unstable_flash_serve), + upgradeHttpRaw: flash.upgradeHttpRaw, + listenDatagram: net.createListenDatagram( + ops.op_node_unstable_net_listen_udp, + ops.op_node_unstable_net_listen_unixpacket, + ), + }, + }); + + // FIXME(bartlomieju): temporarily add whole `Deno.core` to + // `Deno[Deno.internal]` namespace. It should be removed and only necessary + // methods should be left there. + ObjectAssign(internals, { + core, + }); + ObjectDefineProperties(finalDenoNs, { pid: util.readOnly(runtimeOptions.pid), ppid: util.readOnly(runtimeOptions.ppid), @@ -463,6 +486,16 @@ function bootstrapMainRuntime(runtimeOptions) { if (runtimeOptions.unstableFlag) { ObjectAssign(finalDenoNs, denoNsUnstable); + // These have to initialized here and not in `90_deno_ns.js` because + // the op function that needs to be passed will be invalidated by creating + // a snapshot + ObjectAssign(finalDenoNs, { + serve: flash.createServe(ops.op_flash_serve), + listenDatagram: net.createListenDatagram( + ops.op_net_listen_udp, + ops.op_net_listen_unixpacket, + ), + }); } // Setup `Deno` global - we're actually overriding already existing global @@ -540,8 +573,39 @@ function bootstrapWorkerRuntime( globalThis.pollForMessages = pollForMessages; + // These have to initialized here and not in `90_deno_ns.js` because + // the op function that needs to be passed will be invalidated by creating + // a snapshot + ObjectAssign(internals, { + nodeUnstable: { + serve: flash.createServe(ops.op_node_unstable_flash_serve), + upgradeHttpRaw: flash.upgradeHttpRaw, + listenDatagram: net.createListenDatagram( + ops.op_node_unstable_net_listen_udp, + ops.op_node_unstable_net_listen_unixpacket, + ), + }, + }); + + // FIXME(bartlomieju): temporarily add whole `Deno.core` to + // `Deno[Deno.internal]` namespace. It should be removed and only necessary + // methods should be left there. + ObjectAssign(internals, { + core, + }); + if (runtimeOptions.unstableFlag) { ObjectAssign(finalDenoNs, denoNsUnstable); + // These have to initialized here and not in `90_deno_ns.js` because + // the op function that needs to be passed will be invalidated by creating + // a snapshot + ObjectAssign(finalDenoNs, { + serve: flash.createServe(ops.op_flash_serve), + listenDatagram: net.createListenDatagram( + ops.op_net_listen_udp, + ops.op_net_listen_unixpacket, + ), + }); } ObjectDefineProperties(finalDenoNs, { pid: util.readOnly(runtimeOptions.pid), -- cgit v1.2.3