Comments (5)
Thanks! That makes more sense. I'm not on the WASI team, but the context will help them when they review this.
Thanks again for your contribution to the community!
from node.
@Timmmm you might want to check out - nodejs/uvwasi#255. I'm not sure how much preview 1 functionality wil be extended in that context so you might want to see if the preview 2 functionality provided via jco is something you want to use instead.
from node.
Hi! Thanks for the feature request! Could you possible provide more context?
It'd be really helpful if you could give us a comparison of the current features vs the proposed ones.
Thank you!
from node.
@nodejs/wasi
from node.
@RedYetiDev sure!
Currently the Node API for WASI is:
In other words when you start a WASI module, the only option for its stdin/out/err are to give real native file handles. This is quite weird and also inconvenient.
It's weird because WASI's environment is fully controlled by Node. When it writes to stdin it isn't executing native code that requires a file handle, it's calling some WASM interface function that Node provides. I presume this design is something to do with the big warning about WASI's filesystem access not being sandboxed at all at the moment. Presumably they've done the very simplest thing - just pass through WASI filesystem calls to the OS. So I think this is probably intended to be temporary anyway.
It's inconvenient because you can't interact with stdin/out/err except via a file descriptor. The only way to do this through Node is by making a file on disk which is not what you would usually want. My use case is a VSCode LSP server; stdio is used for communication.
Another option would be the pipe()
C function, but unfortunately it does not seem to be exposed by Node.
The API should look more like the API for creating a child process, where you can tell it to "pipe"
the streams and then retrieve a stream.Readable
/Writable
for each.
Hope that makes sense! The workaround I am considering is just to fork()
node, and run a module which only starts my WASI program. I think fork()
lets you pipe
the stdio streams, but I haven't actually tried it yet.
from node.
Related Issues (20)
- Verify env parameter when napi_get_uv_event_loop functions is called. HOT 2
- TypeError: Missing internal module 'node:crypto' HOT 14
- Disable `NODE_OPTIONS` via CLI HOT 4
- Node 20 not supporting prepack script HOT 2
- Passing `-j32` for ninja no longer works HOT 24
- Tracking issue: latest ESM Integration support
- Module Hooks cannot be registered from worker thread in 22.2.0+ HOT 18
- [REG 20.9->20.10] stream: Pipe is stopped after error on another pipe from the same source HOT 5
- Update Undici to backport a fix in Node.js 20.x HOT 1
- Not able to download nodejs for windows HOT 1
- Unhandled Error on Start HOT 3
- Support registering worker specific custom ESM loader hooks (Regression from #52706) HOT 10
- Lambdas in node 18.x (18.20.3) and problems with axios HPE_INVALID_HEADER_TOKEN HOT 2
- Xcode
- Relative `require()` in `commonjs` source not processed by ESM Loader HOT 2
- test_runner: `before` hook runs even if it's not followed by any test HOT 7
- The registration order of http server listen depends on the Node.js version HOT 5
- Ambiguous steps in `PACKAGE_IMPORTS_EXPORTS_RESOLVE` reference documentation HOT 8
- Memory leak or GC overrun in sort() HOT 2
- (Discuss) `_stream_*`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node.