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: do not call resolve on URLs with schemes #35903

Closed
wants to merge 10 commits into from

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Oct 31, 2020

Based on advice from webpack project, this PR stops trying to resolve
sources with a webpack:// scheme (or other schemes, as they represent
absolute URLs). Source content is now loaded from the sourcesContent
lookup, if it is populated (allowing for non file:// schemes).

stack-trace:

webpack:///./webpack.js:14
  throw new Error('oh no!')
        ^

Error: oh no!
    at o (/Users/bencoe/oss/node-1/test/fixtures/source-map/webpack.js:1:970)
        -> webpack:///./webpack.js:14:9
    at n (/Users/bencoe/oss/node-1/test/fixtures/source-map/webpack.js:1:952)
        -> webpack:///./webpack.js:10:3

This work is in pursuit of #35325

Refs webpack/webpack#9601

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

CC: @sokra, @nodejs/tooling

mscdex
mscdex previously requested changes Oct 31, 2020
Copy link
Contributor

@mscdex mscdex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we should start including explicit special cases in node core for third party libraries like this. We should be solving this in a more generic way if there is not already some generic API/interface that suffices for webpack.

@bcoe bcoe requested a review from mscdex October 31, 2020 20:58
@bcoe
Copy link
Contributor Author

bcoe commented Oct 31, 2020

@mscdex take another look, I abstracted the logic so that it should apply to any paths with a scheme; I think the resolve logic would have potentially been broken for file:// paths prior to this.

@bcoe bcoe changed the title process: handle webpack:// scheme for source-maps process: handle alternative schemes in source-maps Oct 31, 2020
@bcoe
Copy link
Contributor Author

bcoe commented Oct 31, 2020

@mscdex based on @sokra's reading of the Source Map v3 language, I cleaned up the logic further. If we have scheme:// we shouldn't need to ever resolve.

@bcoe bcoe changed the title process: handle alternative schemes in source-maps errors: handle alternative schemes in source-maps Oct 31, 2020
@bcoe bcoe changed the title errors: handle alternative schemes in source-maps errors: do not call resolve on URLs with schemes Oct 31, 2020
Based on advice from webpack project, this PR stops trying to resolve
sources with a webpack:// scheme (or other schemes, as they represent
absolute URLs). Source content is now loaded from the sourcesContent
lookup, if it is populated (allowing for non file:// schemes).

Refs: nodejs#35325
@nodejs-github-bot
Copy link
Collaborator

Co-authored-by: devsnek <me@gus.host>
lib/internal/source_map/prepare_stack_trace.js Outdated Show resolved Hide resolved
lib/internal/source_map/source_map_cache.js Outdated Show resolved Hide resolved
lib/internal/source_map/source_map_cache.js Outdated Show resolved Hide resolved
lib/internal/source_map/prepare_stack_trace.js Outdated Show resolved Hide resolved
lib/internal/source_map/prepare_stack_trace.js Outdated Show resolved Hide resolved
lib/internal/source_map/prepare_stack_trace.js Outdated Show resolved Hide resolved
lib/internal/source_map/source_map_cache.js Outdated Show resolved Hide resolved
bcoe and others added 5 commits November 1, 2020 10:38
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@bcoe bcoe requested review from aduh95 and devsnek November 1, 2020 16:17
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Nov 2, 2020

@bcoe bcoe added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 2, 2020
@bcoe bcoe requested a review from aduh95 November 2, 2020 14:40
@bcoe
Copy link
Contributor Author

bcoe commented Nov 2, 2020

👋 if no one objects, I'd like to land this towards the end of the day, since there are a few additional fixes I'd like to make to source-map handling which build on this.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bcoe
Copy link
Contributor Author

bcoe commented Nov 3, 2020

Landed in 26fcdb6

@bcoe bcoe closed this Nov 3, 2020
@bcoe bcoe deleted the webpack-fix branch November 3, 2020 00:31
bcoe added a commit that referenced this pull request Nov 3, 2020
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.

Refs: #35325

PR-URL: #35903
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
targos pushed a commit that referenced this pull request Nov 3, 2020
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.

Refs: #35325

PR-URL: #35903
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@targos targos mentioned this pull request Nov 3, 2020
bcoe added a commit to bcoe/node-1 that referenced this pull request Mar 11, 2021
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.

Refs: nodejs#35325

PR-URL: nodejs#35903
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
bcoe added a commit to bcoe/node-1 that referenced this pull request Mar 11, 2021
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.

Refs: nodejs#35325

Backport-PR-URL: nodejs#37717
PR-URL: nodejs#35903
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
bcoe added a commit to bcoe/node-1 that referenced this pull request Mar 16, 2021
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.

Refs: nodejs#35325

Backport-PR-URL: nodejs#37717
PR-URL: nodejs#35903
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
bcoe added a commit to bcoe/node-1 that referenced this pull request Apr 4, 2021
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.

Refs: nodejs#35325

Backport-PR-URL: nodejs#37717
PR-URL: nodejs#35903
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
targos pushed a commit to bcoe/node-1 that referenced this pull request Apr 24, 2021
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.

Refs: nodejs#35325

PR-URL: nodejs#35903
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
targos pushed a commit that referenced this pull request Apr 25, 2021
We were incorrectly trying to run path.resolve on absolute
sources URLs. This was breaking webpack:// URLs in stack
trace output.

Refs: #35325

PR-URL: #35903
Backport-PR-URL: #37717
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@targos targos added backported-to-v14.x errors Issues and PRs related to JavaScript errors originated in Node.js core. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. backport-open-v14.x labels Apr 25, 2021
@danielleadams danielleadams mentioned this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants