microsoft / microsoft/vscode-extension-samples

ftpExplorer in tree-view-sample can only retrieve top level files

Open
#1,155 0 comments 0 reactions 1 assignee View on GitHub

@alexr00 is already working on this.

Since Mar 13, 2025.

bug
Dominant language
TypeScript
Stars
10.2k
Forks
3.9k
PR merge metrics
No merged PRs in 30d

Description

Extension sample

tree-view-sample

VS Code version

1.98.1 (Universal)

What went wrong?

In the tree-view-sample, the FTP explorer can retrieve files only from the top level directory (/) of an FTP server. Attempting to retrieve files from a subdirectory failes with an error.

Steps to reproduce:

  1. Clone the repository.
  2. Open the tree-view-sample subdirectory in Visual Studio Code.
  3. Since the code uses an FTP server that doesn't work anymore, edit ftpExplorer.ts and change the server. For example:
diff --git a/tree-view-sample/src/ftpExplorer.ts b/tree-view-sample/src/ftpExplorer.ts
index 4bb05ccd..c0218188 100644
--- a/tree-view-sample/src/ftpExplorer.ts
+++ b/tree-view-sample/src/ftpExplorer.ts
@@ -148,7 +148,7 @@ export class FtpExplorer {

        constructor(context: vscode.ExtensionContext) {
                /* Please note that login information is hardcoded only for this example purpose and recommended not to do it in general. */
-               const ftpModel = new FtpModel('mirror.switch.ch', 'anonymous', 'anonymous@anonymous.de');
+               const ftpModel = new FtpModel('test.rebex.net', 'anonymous', 'anonymous@anonymous.de');
                const treeDataProvider = new FtpTreeDataProvider(ftpModel);
                context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider('ftp', treeDataProvider));
  1. Start to debug the extension.
  2. Go to "FTP explorer" and click on the top level readme.txt file. The content on the file should be displayed.
  3. Close the readme.txt file tab in the editor.
  4. In the "FTP explorer" pane, navigate to /pub/example and click on the readme.txt from this directory.

Expected behaviour: the file is retrieved and displayed just like the top level readme.txt.

Actual behaviour: no file is displayed and the parent VSCode window displays this error in the debug console:

rejected promise not handled within 1 second: CodeExpectedError: cannot open file:///pub/example/readme.txt. Detail: Unable to read file '/pub/example/readme.txt' (Error: Unable to resolve nonexistent file '/pub/example/readme.txt')
extensionHostProcess.js:178
stack trace: CodeExpectedError: cannot open file:///pub/example/readme.txt. Detail: Unable to read file '/pub/example/readme.txt' (Error: Unable to resolve nonexistent file '/pub/example/readme.txt')
    at i7e.$tryOpenDocument (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1246:8627)```

Downloading /pub/example/readme.txt with an FTP client works.
This issue was observed on all tested FTP servers.

Repository HEAD: 46f526c39cb454d9d9cb9b3adbe86ba2c9a2ee12
npm: 11.1.0
node: 22.14.0

Contributor guide

Open the contributing guide

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.