Skip to content

fix(sftp): cancel stalled connections and prevent delayed errors - #2791

Merged
bajrangCoder merged 2 commits into
mainfrom
fix/sftp-connection-cancellation
Aug 22, 2026
Merged

fix(sftp): cancel stalled connections and prevent delayed errors#2791
bajrangCoder merged 2 commits into
mainfrom
fix/sftp-connection-cancellation

Conversation

@bajrangCoder

Copy link
Copy Markdown
Member

No description provided.

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds cancellable, timeout-bounded SFTP profile validation and updates loader cancellation semantics to prevent delayed connection errors.

  • Adds request-scoped native SFTP connection attempts with cancellation and bounded connection timeouts.
  • Keeps profile validation and working-directory lookup under the same connection lock, preventing another profile from replacing the connection between those operations.
  • Updates remote-storage and file-browser flows to invoke cancellation only in response to an explicit user action.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/plugins/sftp/src/com/foxdebug/sftp/Sftp.java Adds request-scoped profile connection tasks, bounded timeouts, cancellation, and atomic validation under the shared connection lock; the previously reported replacement race is fixed.
src/lib/remoteStorage.js Uses the new profile-test API and forwards explicit loader cancellation to the corresponding native request.
src/dialogs/loader.js Separates explicit user cancellation from ordinary loader destruction and safely clears delayed cancel-button state.
src/fileSystem/sftp.js Exposes single-attempt profile testing and request-scoped cancellation through the filesystem adapter.
src/pages/fileBrowser/fileBrowser.js Adopts the corrected loader oncancel contract for remote directory navigation.
src/plugins/sftp/www/sftp.js Adds Cordova bridge methods for testing and cancelling profile connections.
src/plugins/sftp/index.d.ts Declares the new native bridge methods and callback contracts.

Sequence Diagram

sequenceDiagram
    participant User
    participant Loader
    participant RemoteStorage
    participant SftpBridge
    participant NativeSftp
    User->>RemoteStorage: Add or edit SFTP profile
    RemoteStorage->>Loader: Show cancellable loader
    RemoteStorage->>SftpBridge: testProfile(profileId, requestId, timeout)
    SftpBridge->>NativeSftp: Start request-scoped connection attempt
    NativeSftp->>NativeSftp: Establish and validate under connectionLock
    alt Connection succeeds
        NativeSftp-->>RemoteStorage: Working directory
        RemoteStorage->>Loader: Destroy loader
    else User cancels
        User->>Loader: Cancel
        Loader->>RemoteStorage: oncancel()
        RemoteStorage->>SftpBridge: cancelConnection(requestId)
        SftpBridge->>NativeSftp: Cancel matching attempt
    else Connection fails or times out
        NativeSftp-->>RemoteStorage: Connection error
        RemoteStorage->>Loader: Destroy loader
    end
Loading

Reviews (2): Last reviewed commit: "fix race cases" | Re-trigger Greptile

Comment thread src/plugins/sftp/src/com/foxdebug/sftp/Sftp.java Outdated
@bajrangCoder

This comment was marked as outdated.

@bajrangCoder
bajrangCoder added this pull request to the merge queue Aug 22, 2026
Merged via the queue into main with commit f90fc1d Aug 22, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Aug 22, 2026
@bajrangCoder
bajrangCoder deleted the fix/sftp-connection-cancellation branch August 22, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant