microsoft / microsoft/vscode-extension-samples
ftpExplorer in tree-view-sample can only retrieve top level files
@alexr00 is already working on this.
Since Mar 13, 2025.
- 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:
- Clone the repository.
- Open the
tree-view-samplesubdirectory in Visual Studio Code. - Since the code uses an FTP server that doesn't work anymore, edit
ftpExplorer.tsand 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));
- Start to debug the extension.
- Go to "FTP explorer" and click on the top level
readme.txtfile. The content on the file should be displayed. - Close the
readme.txtfile tab in the editor. - In the "FTP explorer" pane, navigate to
/pub/exampleand click on thereadme.txtfrom 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.