microsoft / microsoft/vscode-wasm

Questions regarding MemoryFileSystem and Stdio

Open
#143 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
456
Forks
40
Avg merge
3d 2h
Merged PRs (30d)
4

Description

Hi,

First of all thank you for this extension, this is a great job!

I have few questions regarding MemoryFileSystem and Stdio.

First here is my current code i'm trying to get worked.

const pty = wasm.createPseudoterminal();
const terminal = vscode.window.createTerminal({ name: 'PIMO output', pty, isTransient: true });
terminal.show(true);
try {
            const wasmPath = path.resolve(__dirname, "wasm/pimo-wasi.wasm");
            const bits = await vscode.workspace.fs.readFile(vscode.Uri.file(wasmPath));
            const module = await WebAssembly.compile(bits);

            const fs = await wasm.createMemoryFileSystem();
            fs.createFile("masking.yml", new TextEncoder().encode(masking));

            const output = wasm.createReadable();
            const input = wasm.createWritable();
            await input.write(data);
            await input.write(Uint8Array.from([0x0A,0x04])); // end of input (EOF)

            const mountPoints: MountPointDescriptor[] = [
                { kind: 'workspaceFolder'},
                { kind: 'memoryFileSystem', fileSystem: fs, mountPoint: '/memory' }
            ];
            
            const rootfs = await wasm.createRootFileSystem(mountPoints);

            const stdio: Stdio = {
                in: {kind: "pipeIn", pipe: input},
                out: {kind: "pipeOut", pipe: output},
                err: {kind: "terminal", terminal: pty}
            };
            
            // Create a WASM process.
           const process = await wasm.createProcess('pimo', module, { stdio: stdio, args: ["-c", "/memory/masking.yml", "-v", "5"], rootFileSystem: rootfs, trace: true });
            process.stdout?.onData(data => {
                console.log(new TextDecoder().decode(data));
            });

            // Run the process and wait for its result.
            const result = await process.run();
            console.log("success " + result);
        } catch (error) {
            console.error(error);
        }

My questions are :

1 - the process reads an input of type pipeIn created with a wasm.createWritable() call, but it does not seem to catch the EOF and hang indefinitly waiting for more bytes. How can I indicates to the process that there nothing more and it should end ?
2 - at some point, the process reads a file /memory/masking.yml that is created by a call to fs.createFile("masking.yml", ...), the file exist I can get a stat (it is a regular file) but the process get an error Errno.perm ("Operation is not permitted") when trying to read it (call to path_open). Is it something I'm doing wrong ? or maybe the wasm file is not correct (i use the go compiler 1.21)

Thank you in advance ! Any help appreciated

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the createWritable, createMemoryFileSystem, createRootFileSystem, and process.run APIs shown in the issue, then reproduce the pipe EOF hang and the path_open permission error with the referenced WASM module. Done means identifying whether the integration or the Go-built module causes each failure and documenting a working process termination and file-read path.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, wasm
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.