From f62e22a6998bc4d0e2b2fc3df8d6a81aac264e7a Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 31 Oct 2023 04:54:43 -0700 Subject: fix(ext/node): tty streams extends net socket (#21026) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Workaround the circular references issue by using a initializer function to give tty stream class to `initStdin`. Fixes https://github.com/denoland/deno/issues/21024 Fixes https://github.com/denoland/deno/issues/20611 Fixes https://github.com/denoland/deno/issues/20890 Fixes https://github.com/denoland/deno/issues/20336 `create-svelte` works now: ``` divy@mini /t/a> ~/gh/deno/target/debug/deno run -A --unstable --reload npm:create-svelte@latest sveltekit-deno create-svelte version 5.1.1 ┌ Welcome to SvelteKit! │ ◇ Which Svelte app template? │ Skeleton project │ ◇ Add type checking with TypeScript? │ Yes, using JavaScript with JSDoc comments │ ◇ Select additional options (use arrow keys/space bar) │ none │ └ Your project is ready! ✔ Type-checked JavaScript https://www.typescriptlang.org/tsconfig#checkJs Install community-maintained integrations: https://github.com/svelte-add/svelte-add Next steps: 1: cd sveltekit-deno 2: npm install 3: git init && git add -A && git commit -m "Initial commit" (optional) 4: npm run dev -- --open To close the dev server, hit Ctrl-C Stuck? Visit us at https://svelte.dev/chat ``` --------- Signed-off-by: Divy Srivastava --- ext/node/polyfills/_process/streams.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ext/node/polyfills/_process') diff --git a/ext/node/polyfills/_process/streams.mjs b/ext/node/polyfills/_process/streams.mjs index 39ee89a82..14d58fcab 100644 --- a/ext/node/polyfills/_process/streams.mjs +++ b/ext/node/polyfills/_process/streams.mjs @@ -13,7 +13,6 @@ import { } from "ext:deno_node/internal/readline/callbacks.mjs"; import { Duplex, Readable, Writable } from "node:stream"; import * as io from "ext:deno_io/12_io.js"; -import * as tty from "node:tty"; import { guessHandleType } from "ext:deno_node/internal_binding/util.ts"; // https://github.com/nodejs/node/blob/00738314828074243c9a52a228ab4c68b04259ef/lib/internal/bootstrap/switches/is_main_thread.js#L41 @@ -112,6 +111,11 @@ const _read = function (size) { ); }; +let readStream; +export function setReadStream(s) { + readStream = s; +} + /** https://nodejs.org/api/process.html#process_process_stdin */ // https://github.com/nodejs/node/blob/v18.12.1/lib/internal/bootstrap/switches/is_main_thread.js#L189 /** Create process.stdin */ @@ -134,7 +138,7 @@ export const initStdin = () => { break; } case "TTY": { - stdin = new tty.ReadStream(fd); + stdin = new readStream(fd); break; } case "PIPE": -- cgit v1.2.3