Skip to content

Commit

Permalink
fix: some fixes for deno compatibility (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
mash-graz authored Feb 29, 2024
1 parent 92f1cfc commit 1420aad
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/preview2-shim/lib/io/worker-io.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions packages/preview2-shim/lib/io/worker-socket-tcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/preview2-shim/lib/io/worker-thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion packages/preview2-shim/lib/nodejs/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
futimesSync,
linkSync,
lstatSync,
lutimesSync,
mkdirSync,
opendirSync,
openSync,
Expand All @@ -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";
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion packages/preview2-shim/lib/nodejs/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);

Expand Down
2 changes: 1 addition & 1 deletion packages/preview2-shim/lib/synckit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function createSyncFn(workerPath, debug, callbackHandler) {
}
return result;
};
worker.unref();
if (worker.unref) worker.unref();
return syncFn;
}

Expand Down

0 comments on commit 1420aad

Please sign in to comment.