Yup members nondeterministically undefined
See original GitHub issueDescribe the bug
Sometimes we get Airbrake reports from production of errors with Yup functions being undefined
, in contexts where the code certainly works when we try to use it, in dev or in production.
Some example snippets:
import { string } from 'yup'
...
const passwordValidations = string().min(8).max(72)
We will sometimes see this error: Cannot read property 'constructor' of undefined
Or perhaps:
import { string, object } from 'yup'
...
const schema = object({
firstName: string(),
lastName: string()
})
with the error: undefined is not a function
This can happen just about anywhere we try to use yup. One of our developers believes it may only happen at invocations at the top level scope of each document, i.e. it may only happen when the page initializes and not later, when yup
is called from inside a function. This, plus the nondeterministic nature of the bug and our near-total inability to reproduce, may suggest a race condition of some kind.
To Reproduce We have never been able to reproduce this bug locally. We only know it exists from Airbrake reports. It is highly nondeterministic. The code otherwise works completely as expected. Yup is the only dependency we have seen exhibit this behavior.
Expected behavior We expect the calls to work deterministically in all cases, not have a probabilistic chance of failing due to what appear to be failed imports.
Platform (please complete the following information):
- Browser: We’ve seen this in all the major browsers
- Version: Both recent versions and older versions
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top GitHub Comments
I am seeing this error as well intermittently without being able to reproduce. We use Yup for dozens of validations on the site and this particular Search component is the only one where the error seems to occur (and it’s at a very low rate).
Below is a stack trace from Rollbar:
Here is the validation function the trace mentions, which is passed to a Formik
validationSchema
prop in a react project.@skh @CaptainLexington - were you able to find a solution for this? We’re getting a very similar stack trace on Rollbar too.