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

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

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Needs Triage
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Tech debt
    • Labels:
    • Documentation Changes Summary:
      Hide
      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.
      Show
      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

              Created:
              Updated: