Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors thrown by openerService.resolveExternalUri not surfaced to MainThreadWindow.$asExternalUri in VS Code Web #162770

Open
jsjoeio opened this issue Oct 5, 2022 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities opener Opener service issues
Milestone

Comments

@jsjoeio
Copy link
Contributor

jsjoeio commented Oct 5, 2022

  • VS Code Version: 1.72.1 (main)
  • OS Version: N/A
  • Browser: Chrome

Steps to Reproduce:

  1. git clone https://github.com/microsoft/vscode.git
  2. run VS Code Web locally
  3. install any extension that uses asExternalUri (i.e. this one)
  4. run command "Hello World"
  5. Open Browser Console

Expected
Should log error thrown 'Could not resolve external URI: ' + resource.toString()

Actual
Nothing

Notes
I believe this happens because there is no try/catch block here:
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/api/browser/mainThreadWindow.ts#L63

When you add a try/catch block there like so:

		try {
			const result = await this.openerService.resolveExternalUri(URI.revive(uriComponents), options);
			return result.resolved;
		} catch (e) {
			console.error('something wrong', e);
		}
		const result = await this.openerService.resolveExternalUri(URI.revive(uriComponents), options);
		return result.resolved;

Then it logs the thrown error

Screenshot
image

Would you accept a PR to fix this?

@vscodenpa
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.71.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Oct 5, 2022

Oops, I put the wrong version. This is off main so it's the latest. Updated issue description.

@rzhao271 rzhao271 assigned joyceerhl and unassigned rzhao271 Oct 6, 2022
@joyceerhl joyceerhl assigned joaomoreno and unassigned joyceerhl Oct 6, 2022
@joaomoreno joaomoreno assigned mjbvz and unassigned joaomoreno Oct 7, 2022
@mjbvz mjbvz added the help wanted Issues identified as good community contribution opportunities label Oct 12, 2022
@mjbvz mjbvz added bug Issue identified by VS Code Team member as probable bug opener Opener service issues labels Dec 5, 2022
@mjbvz mjbvz added this to the Backlog milestone Dec 5, 2022
@mjbvz
Copy link
Collaborator

mjbvz commented Mar 7, 2023

I don't think logging there is correct. Instead extensions should get an exception if asExternalUri throws

Looks like we sort of already do this but not for http uris:

if (matchesScheme(uri, Schemas.http) || matchesScheme(uri, Schemas.https)) {

@joaomoreno The history oI this code is kind of messy but I believe these checks were first added in a6f7aa5

Do you remember why exceptions are ignored for http uris?

@joaomoreno
Copy link
Member

Sorry for the long delay replying.

I don't really remember, other than this being very specific to how URL callbacks are used in vscode.dev/github.dev. Check this one out: f99e1c3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities opener Opener service issues
Projects
None yet
Development

No branches or pull requests

6 participants