-
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 opening raw file descriptors #6529
Comments
Can you be a bit more descriptive? I'm not sure what you mean. |
@ry updated! :) |
@satyarohith is this what you're looking for? https://deno.land/std/fs |
@jacobgc No, I'm trying to replicate the above example using Deno. |
CC @caspervonb |
Related issue #6305 Given that we have an intermediate representation of resources and do not expose file descriptors/handles directly it isn't immediately obvious (to me, at-least) how we should handle this. First thing that comes to mind is a function to adopt foreign descriptors. namespace Deno {
export function foreign(fd : number) : Deno.File; // naming subject to a bikeshedding competition ;)
} However, we can't do that as there is no way to enforce the sandboxing model when random file descriptors can be adopted so that's a dead end. Supporting raw file descriptors as a general thing just can't be done without breaking the sandbox, such a call would at-least require full privileges. But #6305 might be actionable as it's just about fd 3 which is a thing on windows and unix that we can map to a resource. |
It seems possible to get the file path given a file descriptor / handle, and enforce accordingly. However, i agree that we should begin with support for the specific use cases we understand, and not rush to implement generic access to fds/handles. |
To add an example use-case, the Node REF: https://github.com/nodejs/node/blob/master/lib/net.js#L327 Granted, this is marked as legacy in a code comment, but it is still documented in the official docs. REF: https://nodejs.org/api/net.html#net_new_net_socket_options This capability will be required if we wish to support full feature parity in our Node compatibility layer (https://github.com/denoland/deno_std/tree/main/node) for the Relates to: |
There's also no way to use file descriptors (other than stdin/stdout/stderr) with spawned processes as far as I can tell. |
I'm trying to use @clack/prompts with Deno but all prompts fail with: Error: Not implemented: net.Socket.prototype.constructor with fd option
at notImplemented (https://deno.land/[email protected]/node/_utils.ts:23:9)
at new Socket (https://deno.land/[email protected]/node/net.ts:794:7)
at new WriteStream (https://deno.land/[email protected]/node/tty.ts:21:8) The particular usage of In // TODO(kt3k): Implement tty.WriteStream class
export class WriteStream extends Socket {
} I'm interested in knowing if this is on the roadmap/being worked on or if it never will be supported and I'd have to resort to using Node.js instead. |
from #6305
Hi, I just ran into this issue while trying something. On Linux, SystemD socket activation (kinda like inetd) launches the service on-demand with forwarded ports on file descriptors 3 and above, so it appears currently it is not possible to make a SystemD socket-activated Deno service. This is desirable because then I can delegate port-handling to systemd and lock down the service with private networking, and not run the program until the first time someone hits it. Of course from the security standpoint Deno can lock itself down pretty good so it's not super critical here but I was surprised. Cheers. |
I have been informed one additional level of indirection can be used using |
I'm using a npm package, which throws an error:
|
@bartlomieju I'm interested in implementing this missing code, can you give me some insight on where to start? |
I ran into similar issue trying to spin up a new Nuxt 3 app using:
It should use the
I'm running:
and |
@bitsnaps a possible workaround could be to initialize the project with |
@caspervonb @bartlomieju I'm far outside my realm of expertise here, but is there also something we could do specifically for fd 0? It seems to be causing create-svelte and Nuxi to his this issue (e.g. SvelteKit uses the |
@benmccann sorry for a late reply, I missed the notification. We're gonna focus on providing support for |
Fixes #21012 Closes #20855 Fixes #20890 Fixes #20611 Fixes #20336 Fixes `create-svelte` from #17248 Fixes more reports here: - #6529 (comment) - #6529 (comment) - #6529 (comment)
Fixes denoland#21012 Closes denoland#20855 Fixes denoland#20890 Fixes denoland#20611 Fixes denoland#20336 Fixes `create-svelte` from denoland#17248 Fixes more reports here: - denoland#6529 (comment) - denoland#6529 (comment) - denoland#6529 (comment)
The ability to read and write to file descriptors other than stdin, stdout and stderr. See the example of nodejs below to get a better idea.
Node.js example:
The text was updated successfully, but these errors were encountered: