facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 358 forks source link

Potential isRequired bug in v15.8.0 and above #376

Open paulchan14 opened 2 years ago

paulchan14 commented 2 years ago

We have been encountering the following error in our web app when using v15.8.0 or higher. We are using a micro front end-style setup, so I haven't ruled out that it may just be something with our setup - but it works fine at v15.7.2 ---

...application `appName` died in status LOADING_SOURCE_CODE: Cannot read properties of undefined (reading 'isRequired')
     at objectName.methodCall (Component.js:1:__)

At the given line, the component is using func.isRequired. We also have a usage of string.isRequired, but it crashes at the first instance. Looking through the changelog entry for v15.8.0, I don't see anything relating to the isRequired property.

For now, we're reverting to an earlier version, but please let me know if you have any ideas for the more recent versions.

Thanks

ljharb commented 2 years ago

Have you tried v15.8.1? #370 might be related.

ljharb commented 2 years ago

Also, what is "died in status LOADING_SOURCE_CODE" from?

You can see here: https://npm.runkit.com/prop-types that propTypes.func.isRequired is a function, as is propTypes.func.

paulchan14 commented 2 years ago

Have you tried v15.8.1? #370 might be related.

Yes, we were on v15.8.1 when we noticed the error, then I worked backwards until it worked on v15.7.2

Also, what is "died in status LOADING_SOURCE_CODE" from?

I think that's part of our error boundary setup.

ljharb commented 2 years ago

I wonder if it’s some kind of bundle splitting or duplication issue. What is the value of PropTypes?

ankurparihar commented 1 year ago

Facing the same issue with our Gatsby based project.

Even after setting .isRequired, it becomes optional

ljharb commented 1 year ago

@ankurparihar can you provide a repro repo or codesandbox?

ankurparihar commented 1 year ago

Actually, I'm using GatsbyJS+ESLint+prop-types setup

Digging deeper into the problem, I'm getting prop-types related errors in the browser just fine, but not when running ESLint (even though I have enabled necessary rules).

Most likely it's some configuration issue in my .eslintrc, and not a problem with prop-types. I can't reproduce it on codesandbox yet.

I'll update if I find anything.

ljharb commented 1 year ago

eslint isn’t supposed to generate PropTypes errors - those only come from your code actually being run, like in tests.

ankurparihar commented 1 year ago

Oh, okay, I guess that's it, thanks for the clarification.

ljharb commented 1 year ago

ping @paulgpeterson, any update?