VSCodium / vscodium

binary releases of VS Code without MS branding/telemetry/licensing
https://vscodium.com
MIT License
24.9k stars 1.06k forks source link

dont fetch online sourcemaps on runtime #1287

Open milahu opened 1 year ago

milahu commented 1 year ago

Describe the bug

many javascript files in lib/vscode/resources/ have online sourcemaps

example:

$ tail -n1 /nix/store/0y692yyqc4gdx0i6k22hc7nzswxqqg9p-vscodium-1.71.2.22258/lib/vscode/resources/app/out/bootstrap.js
//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/cea9d1a4b17966719d8c5f3cdd914480f7cec47c/core/bootstrap.js.map

this is unwanted because

  1. vscodium should work offline
  2. vscodium should not call home to windows.net (telemetry)

Please confirm that this problem is VSCodium-specific

Please confirm that the issue/resolution isn't already documented

Additional context Add any other context about the problem here.

on nixos linux ...

find /nix/store/0y692yyqc4gdx0i6k22hc7nzswxqqg9p-vscodium-1.71.2.22258/lib/vscode/resources/ -name '*.js' | xargs tail -n1 -q | sed 's|//# sourceMappingURL=|\n&|g' | grep -E -o 'https://.*?\.js\.map' >/tmp/vscodium-online-sourcemaps.txt

vscodium-online-sourcemaps.txt

daiyam commented 1 year ago

@milahu yes, they are loaded only if you open the Developer Tools in the Help menu. Should we keep them? I don't know.

milahu commented 1 year ago

also some stack traces will (try to) fetch these sourcemaps

sourcemaps are useful for debugging, so ideally, prefetch the sourcemaps on build, and patch the urls

milahu commented 1 year ago

some stack traces will (try to) fetch these sourcemaps

... to ${workdir}/sourcemaps, but this fails in my case

debug console:

Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/vs/loader.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/vs/loader.js.map'

``` Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/vs/loader.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/vs/loader.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/vs/base/common/performance.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/vs/base/common/performance.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/bootstrap-node.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/bootstrap-node.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/bootstrap-amd.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/bootstrap-amd.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/bootstrap.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/bootstrap.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/bootstrap-fork.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/bootstrap-fork.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/vs/workbench/api/node/extensionHostProcess.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/vs/workbench/api/node/extensionHostProcess.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/out/vs/workbench/api/node/extensionHostProcess.nls.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/core/vs/workbench/api/node/extensionHostProcess.nls.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/extensions/debug-auto-launch/dist/extension.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/extensions/debug-auto-launch/dist/extension.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/extensions/ipynb/dist/ipynbMain.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/extensions/ipynb/dist/ipynbMain.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/extensions/emmet/dist/node/emmetNodeMain.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/extensions/emmet/dist/node/emmetNodeMain.js.map' Could not read source map for file:///nix/store/xzpplq37c76fnjyl3nzgwdpb038yqvhx-vscodium-1.72.0.22279/lib/vscode/resources/app/extensions/merge-conflict/dist/mergeConflictMain.js: ENOENT: no such file or directory, open '/tmp/project/sourcemaps/9f4a41aac91eb148c23b6956be66db333af2d3a2/extensions/merge-conflict/dist/mergeConflictMain.js.map' ```

... caused by debugging an vscode extension (vscode-nix-ide)

daiyam commented 1 year ago

To be useful, the sourcemaps need to hosted somewhere since MS don't include them since they would increase the install size of the app.

vscodium should work offline

Since the url needs to be hardcoded, to use a local url would be difficult (for all systems). And the weight of those files can be an issue to include them adhoc.

It only an issue to debug vscode or one of its components.

milahu commented 1 year ago

Since the url needs to be hardcoded, to use a local url would be difficult (for all systems)

sourceMappingURL can be a filename, then its relative to dirname

MS don't include them since they would increase the install size of the app.

maybe we can compress them as .js.map.gz?

but there is another problem ...

vscodium-online-sourcemaps.txt

all URLs produce HTTP 404, because sourcemaps are only generated in macos builds, and there is no macos build for my vscode versions

https://github.com/microsoft/vscode/issues/39824 https://github.com/Microsoft/vscode/issues/43487

daiyam commented 1 year ago

sourceMappingURL can be a filename, then its relative to dirname

I know... but the app is installed at different locations. Unless if we can specify a standard location like the user profile or in the same directory as the extensions, it will be difficult. Then, you will need to download a tar.gz or zip file and uncompress the maps to that location.

daiyam commented 1 year ago

Maybe a script that do all of that??? Locate the app, get the version, download the maps and update the urls.... ???

Hum, Snap, AppImage and macOS might be an issue.

daiyam commented 1 year ago

all URLs produce HTTP 404, because sourcemaps are only generated in macos builds, and there is no macos build for my vscode versions

Yeah, I forgot... it must be linked the BUILD_SOURCEVERSION which is now different between VSCode and VSCodium (due to the release number) So a solution is needed, either remove them or find a solution to have them locally...

GitMensch commented 1 year ago

So a solution is needed, either remove them or find a solution to have them locally...

Generating them with the CI build and ideally have them uploaded along with changing the URL. Additional: a script that change the URLs to the home directory and the option to download them packed.

... wishful thinking ...

Crystal-RainSlide commented 1 year ago

One may just turn off "Enable JavaScript source maps" in the Chromium Dev Tools settings:

Chromium Dev Tools settings

This is electron.devtools.preferences.jsSourceMapsEnabled: "true" | "false" (yes, string), in the <user data directory, see this>/Preferences file, a JSON file without a proper .json suffix.

Since we have good reasons, maybe we can just preload this preference and tell user about this change somewhere.


But... This is related to a larger topic: Should the Web Dev Tools fetch source maps automatically? Should source map errors be printed on the main console? Personally, I want Dev Tools do nothing when I launch them, but fetch the source map when I inspect a source. The source map fetch errors should be printed to somewhere else, like Firefox's browser console. Maybe just leave one `info` level message on the main console, to indicate there is source map error(s) on this Dev Tools instance. Source map is just for convenience, not essential. It shoule be fetched on demand, not unconditionally.
r3m0t commented 1 year ago

To be useful, the sourcemaps need to hosted somewhere since MS don't include them since they would increase the install size of the app.

vscodium should work offline

Since the url needs to be hardcoded, to use a local url would be difficult (for all systems). And the weight of those files can be an issue to include them adhoc.

It only an issue to debug vscode or one of its components.

I think this needs to be an option- I can't debug my vscodium without these source maps, so they should be included. For the VSCodium that's downloadable on GitHub, we can assume nobody will use the source map so the sourceMappingURL line can be removed, or the domain name replaced with a .invalid domain.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment, and we'll keep it open. If you have any new additional information, please include it with your comment!

daiyam commented 1 year ago

+1

milahu commented 1 year ago

but there is another problem ...

vscodium-online-sourcemaps.txt

all URLs produce HTTP 404, because sourcemaps are only generated in macos builds

or you know... build vscodium from source #887 #420

one downside is the long build time this could be reduced by replacing tsc with swc, see also https://github.com/microsoft/vscode/pull/163660

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment, and we'll keep it open. If you have any new additional information, please include it with your comment!

daiyam commented 6 months ago

+1

github-actions[bot] commented 1 day ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment, and we'll keep it open. If you have any new additional information, please include it with your comment!

milahu commented 1 day ago

still an issue