Skip to content

Web extension with github-repositories fs: "Unable to resolve nonexistent file" #250952

Open
@mb21

Description

@mb21

Does this issue occur when all extensions are disabled?: No

Steps to Reproduce:

Build a dummy extension with the following code:

import * as vscode from "vscode";

export const activate = async (context: vscode.ExtensionContext) => {
  context.subscriptions.push(
    vscode.commands.registerCommand("mastro.preview", async () => {
      const rootFolder = vscode.workspace.workspaceFolders?.[0]?.uri;
      if (!rootFolder) return;

      const wsedit = new vscode.WorkspaceEdit();
      wsedit.createFile(rootFolder.with({ path: "/docs/foo.html" }));
      wsedit.createFile(rootFolder.with({ path: "/docs/news/index.html" }));
      wsedit.createFile(rootFolder.with({ path: "/docs/news/2024-01-30-hello-world/index.html" }));
      console.log(await vscode.workspace.applyEdit(wsedit));
    })
  )
}

Run it with vscode-test-web.

Expected: no error and all three files created.
Actual: it creates the first and third file, but the second one is missing and it logs the error:

ERR Ta: Unable to resolve nonexistent file 'vscode-test-web://mount/docs/news/index.html'
    at Ybt.resolve (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:3353:95574)
    at async Ybt.createFile (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:3353:97265)
    at async Promise.all (index 1)
    at async Object.e [as settled] (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:30:80959)
    at async G6e.doCreateFileOrFolder (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:674:8794)
    at async fxe.perform (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:2557:9793)
    at async Olt.apply (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:2557:12710)
    at async Wlt.n (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:2557:18759)
    at async Wlt.perform (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:2557:18416)
    at async jlt.apply (http://localhost:3000/static/build/out/vs/workbench/workbench.web.main.internal.js:2557:20360)

as well as the warning:

WARN IGNORING workspace edit: Error: Unable to resolve nonexistent file 'vscode-test-web://mount/docs/news/index.html'
warn @ log.ts:450
warn @ log.ts:559
warn @ logService.ts:47
(anonymous) @ mainThreadBulkEdits.ts:34
Promise.then
$tryApplyWorkspaceEdit @ mainThreadBulkEdits.ts:33
S @ rpcProtocol.ts:458
Q @ rpcProtocol.ts:443
M @ rpcProtocol.ts:373
L @ rpcProtocol.ts:308
(anonymous) @ rpcProtocol.ts:161
B @ event.ts:1219
fire @ event.ts:1250
D.o.onmessage @ webWorkerExtensionHost.ts:230
Version: 1.101.0-insider
Commit: f832c6b59a2ed11890f4988a29e85658b092a69a

Note: this seems similar to #226173, which could no longer be reproduced.

Question: vscode.workspace.fs.writeFile seems to work fine. Is there any advantage to using WorkspaceEdit, as it doesn't seem to atomically fail anyway, i.e. even when it fails some files are created?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions