Skip to content

Conversation

@bcoe
Copy link
Contributor

@bcoebcoe 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

@bcoebcoe requested review from boneskull and devsnekOctober 31, 2020 17:19
mscdex
mscdex previously requested changes Oct 31, 2020
Copy link
Contributor

@mscdexmscdex 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.

@bcoebcoe requested a review from mscdexOctober 31, 2020 20:58
@bcoe
Copy link
ContributorAuthor

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.

@bcoebcoe changed the title process: handle webpack:// scheme for source-mapsprocess: handle alternative schemes in source-mapsOct 31, 2020
@bcoe
Copy link
ContributorAuthor

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.

@bcoebcoe changed the title process: handle alternative schemes in source-mapserrors: handle alternative schemes in source-mapsOct 31, 2020
@bcoebcoe changed the title errors: handle alternative schemes in source-mapserrors: do not call resolve on URLs with schemesOct 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

@bcoebcoe requested review from aduh95 and devsnekNovember 1, 2020 16:17
Co-authored-by: Antoine du Hamel <[email protected]>
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Nov 2, 2020

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

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

@mcollinamcollina 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
ContributorAuthor

bcoe commented Nov 3, 2020

Landed in 26fcdb6

@bcoebcoe closed this Nov 3, 2020
@bcoebcoe deleted the webpack-fix branch November 3, 2020 00:31
bcoe 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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
@targostargos mentioned this pull request Nov 3, 2020
bcoe pushed 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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
bcoe pushed 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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
bcoe pushed 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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
bcoe pushed 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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
@targostargos 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
@danielleadamsdanielleadams mentioned this pull request May 3, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

errorsIssues and PRs related to JavaScript errors originated in Node.js core.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@bcoe@nodejs-github-bot@mcollina@mscdex@Trott@sokra@devsnek@aduh95@targos@BethGriggs