Repository navigation
fix: give a plugin process's SFTP session the events ssh2's has - #1961
Open
ZacharyZcR wants to merge 1 commit into
Open
ZacharyZcR wants to merge 1 commit into
ZacharyZcR wants to merge 1 commit into
Conversation
|
AI review | Looks safe to merge Refactors the SFTP proxy into a dedicated module and adds EventEmitter support to fix plugin compatibility errors. The change is safe, follows repository standards, and includes appropriate tests. Reviewed 0b5f913. AI can be wrong, a maintainer still decides. Comment |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Termix-SSH/Plugin-File-Manager#63
In a plugin process,
client.sftp()on a connection fromctx.ssh.connecthands backsftpProxy(...), a plain object with the SFTP calls on it. ssh2'sSFTPWrapperis an EventEmitter, and plugins written against it listen on it straight away. File Manager doessftp.on("error", ...)andsftp.on("close", ...)when it opens one (getSessionSftp,openDedicatedSftp). So every cross-host "Copy to host..." on 26.11.2 and later failed in about a second withsftp.on is not a function, because its dedicated transfer connection comes fromctx.ssh.connect.Change
sftpProxyand its helpers (SFTP_METHODS,withStats) move fromchild/runtime.tstochild/sftp-proxy.ts, the same waysocket.tsandrequest-body.tssit beside it. The endpoint is passed in, so it can be tested without a plugin process.closeonce, when it ends or when its SSH connection closes, so a plugin that caches its SFTP session (File Manager does) drops it as it would with ssh2.sftp.call,sftp.read,sftp.write,sftp.end) are unchanged.Testing
src/backend/tests/plugins/sandbox/child/sftp-proxy.test.tschecks that:onworks;sftp.calland stats come back withisFile();closefires once, from either the connection closing orend(), and the listener on the connection is removed.supervisor.test.tsspawns real plugin processes: 25 of 29 pass, the same as ondev-26.11.4without this change. The other 4 are timing tests that fail the same way here.tsc -p tsconfig.node.jsonare clean.