refactor!: replace WebSocket/TCP transport with Unix socket / Windows named pipe#1699
refactor!: replace WebSocket/TCP transport with Unix socket / Windows named pipe#1699eitsupi wants to merge 10 commits intoREditorSupport:masterfrom
Conversation
Replace the WebSocket-over-TCP IPC between vscode and R sessions with a Unix domain socket (Linux/Mac) or Windows named pipe transport. Changes: - session.ts: create net.Server pipe instead of WebSocket.Server; use NDJSON framing (\n-delimited JSON) for message boundaries; remove token-based authentication (filesystem permissions suffice) - rTerminal.ts: pass SESS_PIPE env var instead of SESS_PORT + SESS_TOKEN - sess/R/server.R: connect via processx::conn_connect_unix_socket(); drive message dispatch through a later::later() polling loop - sess/R/dispatch.R: send via processx::conn_write() + NDJSON framing - sess/DESCRIPTION: swap websocket dep for processx (>= 3.5.0); add testthat to Suggests - sess/tests/testthat/test-ipc.R: unit tests for socket round-trip, dispatch_message routing, and ipc_write guard
b50c828 to
fdc193b
Compare
| # Derive file path for fallback/reconnection | ||
| # Fallback: read from session JSON file written by the extension | ||
| pid <- Sys.getpid() | ||
| home <- path.expand("~") |
There was a problem hiding this comment.
This should refer to My Documents on Windows, so it's probably not what you intended.
There was a problem hiding this comment.
Ya, it is not ideal. It may not be the same "~" inferred by VSCode.
|
thanks for working on it, didn't know that |
|
This branch works for me on macOS. It looks like the dependencies are reduced 👍 . |
|
It would be ok if either eitsupi#1 (which fixes the use case of unmanaged R session) could be merged into this PR, or after this PR being merged into master and I resubmit that PR based on latest master. |
Improve attach
|
Merged, thank you! |
| # Derive file path for fallback/reconnection | ||
| # Fallback: read from session JSON file written by the extension | ||
| pid <- Sys.getpid() | ||
| home <- path.expand("~") |
There was a problem hiding this comment.
Ya, it is not ideal. It may not be the same "~" inferred by VSCode.
| await fs.writeFile(scriptPath, buildAttachSessionScript(pipePath, sessPath), { encoding: 'utf-8' }); | ||
| attachSessionScriptPath = scriptPath; | ||
|
|
||
| return `source(${asRStringLiteral(scriptPath)})`; |
|
|
||
| function buildAttachSessionScript(pipePath: string, sessPath: string): string { | ||
| return [ | ||
| 'local({', |
There was a problem hiding this comment.
i wonder how we could make it consistent with the install_sess.R.
Replace the WebSocket-over-TCP IPC between vscode and R sessions with a Unix domain socket (Linux/Mac) or Windows named pipe transport.