-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support npm:pm2 #16753
Comments
Min. example import chalk from "npm:chalk@3"
console.log(chalk.bold.green("Hello")) Errors:
|
I've dissected through the code for chalk v3 and have managed to get pure JS (no deps) code that works in node, but fails in Deno. I'm not completely sure yet but it seems like Node is handling object prototypes differently from Deno, I'll try to get a cleaner example and then post it here |
Note that the code works in node and not in Deno even when not using npm specifiers / createRequire, so this isn't an issue with the npm compatibility layer (or std/node) |
Duplicate of #13321 |
If this is because of chalk@3 then it's because of missing "proto" that Deno doesn't support and will not in the future. So the best bet is to ask pm2 maintainers to update their dependencies. |
Yes, it is because of that -- is there no chance of implementing I've run grep through the node_modules of the top 10 packages on npm and nearly all of them have |
FYI, @khrj is aiming to fix this in Unitech/pm2#5489 |
Note that even after proto is fixed, pm2 will still be broken by #16784 |
This still doesn't work for me. It appears that we're not correctly handling "ipc" option in Spawning PM2 daemon with pm2_home=/Users/ib/.pm2
spawning
caught error Error: Not implemented: toDenoStdio pipe=string (ipc)
at notImplemented (ext:deno_node/_utils.ts:27:9)
at toDenoStdio (ext:deno_node/internal/child_process.ts:379:5)
at new ChildProcess (ext:deno_node/internal/child_process.ts:197:16)
at Object.spawn (node:child_process:192:10)
at module.exports.Client.launchDaemon (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:256:40)
at file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:104:10
at file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:321:14
at Array.processTicksAndRejections (ext:deno_node/_next_tick.ts:37:11)
at eventLoopTick (ext:core/01_core.js:166:29)
error: Uncaught TypeError: Cannot read properties of undefined (reading 'unref')
at ChildProcess.unref (ext:deno_node/internal/child_process.ts:323:19)
at module.exports.Client.launchDaemon (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:274:9)
at file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:104:10
at file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/pm2/5.3.1/lib/Client.js:321:14
at Array.processTicksAndRejections (ext:deno_node/_next_tick.ts:37:11)
at eventLoopTick (ext:core/01_core.js:166:29) CC @littledivy is it something you could look at? Since we already support IPC in subprocesses it feels like there's something misconfigured that makes it crash. |
@bartlomieju I'm not getting the IPC error. It fails on
|
@littledivy - correct. I added additional logs to surface that error (the catch handler for when the process is spawned). |
Ah, I see the problem now. Our implementation only supports non-stdio IPC. We need to implement support for const process = new Deno.Command(command, {
stdout: "ipc",
// or stdout: 3
}).spawn(); |
Huh, i thought we already had it. Is it any different than the current IPC support we have? |
This should be straightforward to implement:
|
…4106) Add supports for "ipc" and fd options in child_process spawn API. Internal changes: Adds a hidden rid and "ipc_for_internal_use" option to Deno.Command. Used by `node:child_process` Example: ```js const out = fs.openSync("./logfile.txt", 'a') const proc = spawn(process.execPath, ["./main.mjs", "child"], { stdio: ["ipc", out, "inherit"] }); ``` Ref #16753
…4106) Add supports for "ipc" and fd options in child_process spawn API. Internal changes: Adds a hidden rid and "ipc_for_internal_use" option to Deno.Command. Used by `node:child_process` Example: ```js const out = fs.openSync("./logfile.txt", 'a') const proc = spawn(process.execPath, ["./main.mjs", "child"], { stdio: ["ipc", out, "inherit"] }); ``` Ref #16753
stdio IPC support landed. A few more things to solve before this works: By default, pm2 spawns its daemon using node (hard-coded). The In BYONM context the daemon spawns but IPC between Deno and Node We have 2 options:
|
It would in general be great to have a way to override nested uses of node with deno, even by default, similar to the '--bun' flag used in that runtime (which will also be default eventually) |
run command
deno run -A npm:pm2 --help
.same error, error info is
x.y.z is not a function
.Originally posted by @iugo in #16679 (comment)
The text was updated successfully, but these errors were encountered: