Repository navigation
Conversation
sess now sends attach as a protocol v3 JSON-RPC request and waits up to five seconds for the matching acknowledgement before starting its runtime. Frames that arrive with the acknowledgement are handed to the first poll in order. The extension and the Interactive bridge write the acknowledgement before publishing the connection, so no editor-initiated RPC can precede it. A rejection ends automatic retries for the R process; a timeout or an EOF before the acknowledgement retries the same endpoint as before. Both receivers acknowledge with a null jdv result for now.
The extension starts a jdv listener for each native sess connection and returns its address in the attach acknowledgement, so R no longer asks for it with a synchronous jdv/address request. The first View() from the Workspace Viewer, or a list navigated to a table while R answers a request, now opens in jdv instead of falling back to the sess data viewer. The listener belongs to one connection: a reconnect, an attach from another window or a replaced connection gets a new address, and the old listener is closed. If the listener cannot start within three seconds, the attach still succeeds and reports why jdv is unavailable.
renkun-ken
left a comment
There was a problem hiding this comment.
I reproduced two cases where a terminal loses session-watcher functionality during attachment. The five focused R suites passed all 352 assertions, and the six jdv transport tests passed. The inline comments include a fresh R profile case and a VS Code extension-host case for regression coverage.
| if (!length(parts) || endsWith(buffer, "\n")) { | ||
| return(list(lines = parts, tail = "")) | ||
| } | ||
| list(lines = head(parts, -1L), tail = parts[[length(parts)]]) |
There was a problem hiding this comment.
Handle a partial frame during R profile startup. The terminal profile calls connect() before R attaches utils. Sending the acknowledgement in two chunks made .await_attach() fail on the first chunk with could not find function "head", leaving the session disconnected. The same branch runs if the first read contains the acknowledgement and part of the next request. parts[-length(parts)] or utils::head(parts, -1L) handles both cases. A fragmented acknowledgement delivered from R_PROFILE_USER reproduces this with the ordinary startup search path.
| const superseded = pendingSessionAttachments.get(sessionId); | ||
| if (superseded) { | ||
| const unpublished = !superseded.socket._sessionId; | ||
| cancelSessionAttachment(superseded); |
There was a problem hiding this comment.
Keep the live attachment’s terminal lookup until its replacement commits. I held the first connection’s terminal.processId lookup open after it received its acknowledgement, then closed a second socket with the same session ID while its jdv listener was starting. The original socket and session reference stayed live, but resolving its exact terminal PID no longer bound or activated the terminal. This cancellation makes isCurrentAttachment() return false. Cancel an unpublished contender immediately and defer cancellation of a published connection’s lookup until the replacement commits. With that ordering, the same extension-host test bound and activated the original terminal.
…erminal lookup A terminal profile calls connect() before R attaches utils, so splitting a partially received attach acknowledgement with head() failed and left the session disconnected. Frame splitting now uses base R only. A second attach for the same session cancelled the terminal lookup of the connection already published, even if the new attempt was abandoned before it committed. The published connection then never bound its terminal. Its lookup is now cancelled only when the replacement commits; an abandoned attempt hands the pending lookup back to it.
renkun-ken
left a comment
There was a problem hiding this comment.
Both runtime fixes passed on 000310f. A fragmented acknowledgement now works before utils attaches, and an abandoned replacement leaves the original terminal lookup able to bind and activate. The focused R suites passed 353 assertions locally, and four extension-host tests passed. There is one remaining issue in the new Windows test invocation.
| output <- suppressWarnings(system2( | ||
| file.path(R.home("bin"), "Rscript"), | ||
| c("--vanilla", "-e", shQuote(code)), | ||
| env = c( |
There was a problem hiding this comment.
Launch the minimal R child portably on Windows. Windows system2() passes these env strings on the command line before --vanilla. Rscript then treats R_DEFAULT_PACKAGES=NULL as its script filename and exits before evaluating the frame-splitting assertion. The Windows job fails here with an empty output. processx::run() can pass the code as a single argument, --default-packages=NULL as an Rscript option, and R_LIBS in the child environment. I checked that invocation returns split-ok. Failing Windows job
system2() on Windows puts env strings on the command line before the Rscript options, so Rscript took R_DEFAULT_PACKAGES=NULL as its script name. Use processx::run() with --default-packages=NULL instead, and assert that utils is not attached in the child.
renkun-ken
left a comment
There was a problem hiding this comment.
The Windows regression is fixed in f00a354. The child now receives --default-packages=NULL as an Rscript option and R_LIBS through its environment. The test confirms utils is absent before exercising the fragmented frame. All 158 assertions in test-ipc.R passed locally, and all 14 CI checks passed, including Windows Node and Extension. The earlier terminal-lookup and frame-splitting fixes are still in place. Approved.
When the data viewer was opened from the Workspace Viewer before any
View()in the terminal, sess had to ask VS Code for the jdv listener address with a synchronousjdv/addressrequest. R cannot read that reply while it is answering a socket request, so the first view fell back to the sess data viewer. Navigating from a list to a table hit the same limitation.sess now sends
attachas a JSON-RPC request (protocol version 3) and waits for the matching acknowledgement before starting its runtime. For a terminal session, the extension starts a jdv listener for that connection and returns its address in the acknowledgement, so R already knows where to open views and never sendsjdv/address. The first view from the Workspace Viewer and list-to-table navigation now open in jdv.{"jdv": null}; Interactive sessions still resolve the controller's listener as before.This is a breaking change to the sess wire protocol: the extension requires the sess package from the same release; the extension rejects an attach from an older sess. The handshake is documented in
sess/README.md.