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

SourceRoot not Considered as Absolute Path #1424

Open
FrankEssenberger opened this issue Oct 10, 2022 · 5 comments
Open

SourceRoot not Considered as Absolute Path #1424

FrankEssenberger opened this issue Oct 10, 2022 · 5 comments
Assignees
Labels
feature-request Request for new features or functionality good first issue Issues identified as good for first-time contributors

Comments

@FrankEssenberger
Copy link

Describe the bug

Here is a small sample repo.

We try to use the sourceRoot to add the sources in a remote location so that we do not need to ship them. However, the mapping:

{"version":3,"file":"string.js","sourceRoot":"http:/raw.githubusercontent.com/SAP/cloud-sdk-js/main/packages/util/src/","sources":["string.ts"],"names":[],"mappings":";......"}

leads to an error because the CWD is added in front of the source route.

To Reproduce

  • Checkout repo.
  • Run install
  • Execute debug-test.mjs via launch.json
  • Step into method -> see the Error

Could not load source '/Users/XXX/source-map-test/node_modules/@sap-cloud-sdk/util/dist/http:/raw.githubusercontent.com/SAP/cloud-sdk-js/main/packages/util/src/string.ts': Unable to retrieve source content.

VS Code Version: 1.72.0

@FrankEssenberger FrankEssenberger added the bug Issue identified by VS Code Team member as probable bug label Oct 10, 2022
@connor4312
Copy link
Member

We do not currently support loading remote sources from maps in Node.

However, note that you will also need changes in how you publish sourcemaps. The source root http:/raw.githubusercontent.com/SAP/... is not an absolute path, nor is it a URI. You will want to ensure it's a valid URI, starting with https:// or http:/ if we are to load it.

@connor4312 connor4312 added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug labels Oct 10, 2022
@FrankEssenberger
Copy link
Author

FrankEssenberger commented Oct 11, 2022

@connor4312 Thanks a lot for the quick reply. I guess the / was taken by the join() method of the path module. I made a quick adjustment to the code so that the double slash is there. http works for me but they do some redirect and this does not work for all http clients so https is better - also adjusted this.. Looks like this is also used internally because even when the source root contains the double slash in the map file in the resulting path printed in the error message the double slash is gone.

Anyhow if it is not supported it will not work. Since you said do not currently support is there a hope that you do it in the future? If so do you have a rough timeline?

@connor4312
Copy link
Member

connor4312 commented Oct 11, 2022

I don't have a timeline at the moment, but this may be easy to add. Code pointer:

smContent !== null
? () => Promise.resolve(smContent)
: fileUrl
? () => this.resourceProvider.fetch(fileUrl).then(r => r.body)
: () => compiled.content(),

Currently fileUrl is only a file URL, but if we could do an extra check to see if the resolvedUrl is a correctly formed URL, and if so pass that as a fileUrl contentUrl instead

@connor4312 connor4312 added the good first issue Issues identified as good for first-time contributors label Oct 11, 2022
@FrankEssenberger
Copy link
Author

FrankEssenberger commented Oct 12, 2022

I guess there is already a fetchHtt but it is not used because the absolutePath is fooled since the URL is not starting with a /.

This seems simple enough even for me :-) to fix and add a test. Perhaps I do that on our focus friday reserved for learning. DO I simply fork the repo and create a PR?

@connor4312
Copy link
Member

Indeed 🙂 You can check out the contributing guide for setup: https://github.com/microsoft/vscode-js-debug/blob/main/CONTRIBUTING.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality good first issue Issues identified as good for first-time contributors
Projects
None yet
Development

No branches or pull requests

2 participants