summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/process
diff options
context:
space:
mode:
authorDaniel Mizerski <duelsik@gmail.com>2023-12-01 07:36:11 +0100
committerGitHub <noreply@github.com>2023-12-01 15:36:11 +0900
commit687ae870d1e4e856b7ceee0a5511138459c68cb1 (patch)
tree19ce6f135a8d2edde9892dc43dd0608f744e9466 /ext/node/polyfills/internal/process
parentfe90ba650d926fb006948499a96c9dabb149eed9 (diff)
fix(ext/node): add stubbed process.report (#21373)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Diffstat (limited to 'ext/node/polyfills/internal/process')
-rw-r--r--ext/node/polyfills/internal/process/report.ts84
1 files changed, 84 insertions, 0 deletions
diff --git a/ext/node/polyfills/internal/process/report.ts b/ext/node/polyfills/internal/process/report.ts
new file mode 100644
index 000000000..7d178626c
--- /dev/null
+++ b/ext/node/polyfills/internal/process/report.ts
@@ -0,0 +1,84 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+import { arch, versions } from "ext:deno_node/_process/process.ts";
+import { cpus, hostname, networkInterfaces } from "node:os";
+
+const primordials = globalThis.__bootstrap.primordials;
+const {
+ Error,
+ StringPrototypeToUpperCase,
+ StringPrototypeCharAt,
+ StringPrototypeSlice,
+ Date,
+ DatePrototypeGetTime,
+} = primordials;
+
+function writeReport(_filename: string, _err: typeof Error) {
+ return "";
+}
+
+const todoUndefined = undefined;
+
+function getReport(_err: typeof Error) {
+ const dumpEventTime = new Date();
+ return {
+ header: {
+ reportVersion: 3,
+ event: "JavaScript API",
+ trigger: "GetReport",
+ filename: report.filename, // assumption!
+ dumpEventTime,
+ dumpEventTimeStamp: DatePrototypeGetTime(dumpEventTime),
+ processId: Deno.pid, // I am not sure if it should be Deno.pid or Deno.ppid
+ threadId: 0,
+ cwd: Deno.cwd(),
+ commandLine: ["node"],
+ nodejsVersion: `v${versions.node}`,
+ glibcVersionRuntime: "2.38",
+ glibcVersionCompiler: "2.38",
+ wordSize: 64,
+ arch: arch(),
+ platform: Deno.build.os,
+ componentVersions: versions,
+ release: {
+ name: "node",
+ headersUrl:
+ "https://nodejs.org/download/release/v21.2.0/node-v21.2.0-headers.tar.gz",
+ sourceUrl:
+ "https://nodejs.org/download/release/v21.2.0/node-v21.2.0.tar.gz",
+ },
+ osName:
+ StringPrototypeToUpperCase(StringPrototypeCharAt(Deno.build.os, 0)) +
+ StringPrototypeSlice(Deno.build.os, 1),
+ osRelease: todoUndefined,
+ osVersion: todoUndefined,
+ osMachine: Deno.build.arch,
+ cpus: cpus(),
+ networkInterfaces: networkInterfaces(),
+ host: hostname(),
+ },
+ javascriptStack: todoUndefined,
+ javascriptHeap: todoUndefined,
+ nativeStack: todoUndefined,
+ resourceUsage: todoUndefined,
+ uvthreadResourceUsage: todoUndefined,
+ libuv: todoUndefined,
+ workers: [],
+ environmentVariables: todoUndefined,
+ userLimits: todoUndefined,
+ sharedObjects: todoUndefined,
+ };
+}
+
+// https://nodejs.org/api/process.html#processreport
+export const report = {
+ compact: false,
+ directory: "",
+ filename: "",
+ getReport,
+ reportOnFatalError: false,
+ reportOnSignal: false,
+ reportOnUncaughtException: false,
+ signal: "SIGUSR2",
+ writeReport,
+};