Uploaded image for project: 'VS Code Extension'
  1. VS Code Extension
  2. VSCODE-288

try {} catch {} used to wrap asynchronous event callbacks

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • No version
    • Affects Version/s: None
    • Component/s: Tech debt
    • None
    • 3
    • Not Needed

      For this one I'm not sure:
      https://github.com/mongodb-js/vscode/blob/1e98a4e9634fe1f298821a1b894b9a5e24902522/src/explorer/databaseTreeItem.ts#L199-L219

      My guess is that validateInput is not called synchronously (ie. directly after `vscode.window.showInputBox`) so the try/catch won't catch things in there. Therefore I think that try/catch is probably doing nothing. Similar thing everywhere else we use showInputBox.

      Then there are things like this:
      https://github.com/mongodb-js/vscode/blob/main/src/language/mongoDBService.ts#L199-L220

      on('message') almost certainly happens asynchronously and that try/catch only covers the initial synchronous setup.

      I don't know about token.onCancellationRequested. something might await that promise but that thing isn't being awaited in turn, so the catch wrapping it probably isn't doing much.

            Assignee:
            Unassigned Unassigned
            Reporter:
            leroux.bodenstein@mongodb.com Le Roux Bodenstein
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: