diff --git a/packages/preview2-shim/lib/io/worker-io.js b/packages/preview2-shim/lib/io/worker-io.js index 21f63265a..3dd02a7e5 100644 --- a/packages/preview2-shim/lib/io/worker-io.js +++ b/packages/preview2-shim/lib/io/worker-io.js @@ -33,7 +33,10 @@ import { STDOUT, reverseMap, } from "./calls.js"; -import { _rawDebug, exit, stderr, stdout, env } from "node:process"; +import { exit, stderr, stdout, env } from "node:process"; + +import * as nodeProcess from "node:process"; +const _rawDebug = nodeProcess._rawDebug || console.error.bind(console); const workerPath = fileURLToPath( new URL("./worker-thread.js", import.meta.url) diff --git a/packages/preview2-shim/lib/io/worker-socket-tcp.js b/packages/preview2-shim/lib/io/worker-socket-tcp.js index 77283fdb0..6725c94fd 100644 --- a/packages/preview2-shim/lib/io/worker-socket-tcp.js +++ b/packages/preview2-shim/lib/io/worker-socket-tcp.js @@ -8,6 +8,7 @@ import { pollStateReady, verifyPollsDroppedForDrop, } from "./worker-thread.js"; +import process from "node:process"; const { TCP, constants: TCPConstants } = process.binding("tcp_wrap"); import { convertSocketError, diff --git a/packages/preview2-shim/lib/io/worker-thread.js b/packages/preview2-shim/lib/io/worker-thread.js index 94003a366..80dc2e6a6 100644 --- a/packages/preview2-shim/lib/io/worker-thread.js +++ b/packages/preview2-shim/lib/io/worker-thread.js @@ -147,6 +147,7 @@ import { socketUdpStream, udpSockets, } from "./worker-socket-udp.js"; +import process from "node:process"; function log(msg) { if (debug) process._rawDebug(msg); diff --git a/packages/preview2-shim/lib/nodejs/filesystem.js b/packages/preview2-shim/lib/nodejs/filesystem.js index 87b0d1e57..ef7dfe159 100644 --- a/packages/preview2-shim/lib/nodejs/filesystem.js +++ b/packages/preview2-shim/lib/nodejs/filesystem.js @@ -17,7 +17,6 @@ import { futimesSync, linkSync, lstatSync, - lutimesSync, mkdirSync, opendirSync, openSync, @@ -33,6 +32,9 @@ import { } from "node:fs"; import { platform } from "node:process"; +import * as nodeFs from 'node:fs'; +const lutimesSync = nodeFs.lutimesSync; + const symbolDispose = Symbol.dispose || Symbol.for("dispose"); const isWindows = platform === "win32"; @@ -297,6 +299,9 @@ class Descriptor { dataModificationTimestamp.tag === "no-change" && stats.dataModificationTimestamp ); + if (!pathFlags.symlinkFollow && !lutimesSync){ + throw new Error("Changing the timestamps of symlinks isn't supported"); + } try { (pathFlags.symlinkFollow ? utimesSync : lutimesSync)( fullPath, diff --git a/packages/preview2-shim/lib/nodejs/http.js b/packages/preview2-shim/lib/nodejs/http.js index d54b09150..0cf830578 100644 --- a/packages/preview2-shim/lib/nodejs/http.js +++ b/packages/preview2-shim/lib/nodejs/http.js @@ -21,9 +21,11 @@ import { registerDispose, registerIncomingHttpHandler, } from "../io/worker-io.js"; -import { validateHeaderName, validateHeaderValue } from "node:http"; import { HTTP } from "../io/calls.js"; +import * as http from "node:http"; +const { validateHeaderName = () => {}, validateHeaderValue = () => {} } = http; + const symbolDispose = Symbol.dispose || Symbol.for("dispose"); export const _forbiddenHeaders = new Set(["connection", "keep-alive"]); diff --git a/packages/preview2-shim/lib/synckit/index.js b/packages/preview2-shim/lib/synckit/index.js index 88d03ef5d..30c01b25f 100644 --- a/packages/preview2-shim/lib/synckit/index.js +++ b/packages/preview2-shim/lib/synckit/index.js @@ -87,7 +87,7 @@ export function createSyncFn(workerPath, debug, callbackHandler) { } return result; }; - worker.unref(); + if (worker.unref) worker.unref(); return syncFn; }