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

checkPropTypes breaks error stack Source Mapping in Chrome #328

Open
ivoiv opened this issue Sep 26, 2020 · 3 comments
Open

checkPropTypes breaks error stack Source Mapping in Chrome #328

ivoiv opened this issue Sep 26, 2020 · 3 comments

Comments

@ivoiv
Copy link

ivoiv commented Sep 26, 2020

checkPropTypes takes a getStack argument that can be used to send the component or error stack.
It then prints the error stack string at the end of the Warning displayed in the console.

Chrome seemingly expects console.error output to begin with Error in order for it to resolve Source Maps correctly, but the checkPropTypes message sent to console.error begins with the text Warning instead.

This makes Chrome resolve the source to the bundled code rather than using the provided Source Maps.
This is a weird issue for sure and I welcome any feedback on other potential causes.

Link to the responsible line of code in the repo

var message = 'Warning: ' + text;

Changing the text from "Warning: " to "Error: " solves the issue.

Current result: (with Warning)
image

Desired result (with Error)
image

CodeSandBox link with example code:
https://codesandbox.io/s/hungry-snowflake-6qs4v
(Note that it works OK inside CodeSandBox because the way they build the project. It's in localhost where things break down)

Possible solutions:

  1. Change text "Warning: " to "Error: "
  2. Make the warning/error prefix configurable.
  3. Replace Warning with Error when an argument for getStack is provided.

I feel like number 2 is least prone to breaking existing code, as some projects might test for the Warning messages.

I'll be happy to submit a PR for the issue if approved.

@ljharb
Copy link
Collaborator

ljharb commented Feb 15, 2021

To be honest, this seems like a bug in Chrome - it shouldn't matter what string the console output starts with. Has it been filed upstream?

@ljharb
Copy link
Collaborator

ljharb commented May 18, 2021

Can you link to the upstream bug?

@LandonSchropp
Copy link

LandonSchropp commented Aug 5, 2021

@ljharb I'm seeing similar behavior in Firefox. I'm not sure if it's the same underlying issue, but I definitely don't my source maps.

Screen Shot 2021-08-05 at 2 04 38 PM

Here's what a normal error looks like for comparison:

Screen Shot 2021-08-05 at 2 05 18 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants