Running into a strange issue that i cannot reproduce, it happens when running tests in Karma using 16.3.0-alpha.3
The issue is here:
My test is throwing an error because of a missing onChange
handler when rendering a checkbox with checked
but no handler. What appears to be happening is that nextUnitOfWork
is not null
and misses the first branch, replayUnitOfWork
is run, after which nextUnitOfWork
_is_ null and sourceFiber
doesn't exist and so access of return
fails.
I've tried for a while to reproduce it, the following codesandbox is a simplified version of the code that is throwing, but the error isn't present there :/ https://codesandbox.io/s/0332y243zp
Hmm, I was concerned this might happen. We assume that replayUnitOfWork
will be idempotent but looks like you've found a case where it's not. I'll take a look at this.
Changing line 877 to
const sourceFiber: Fiber = failedUnitOfWork;
isn't a sufficient fix because if it's not equal to nextUnitOfWork
, that means the stack is misaligned.
One option is to add an invariant that throws if nextUnitOfWork !== failedUnitOfWork
. Usually we avoid DEV-only invariants, but since this should only be possible in an error case, anyway, maybe we can get away with it.
Btw, there's another potentially related bug that happens if you remove this feature flag override that manifests as an Unexpected pop
warning. Maybe we should change this test suite to use the feature flag that people use in real bundles? This doesn't leave me very confident.
Added failing tests in https://github.com/facebook/react/pull/12508.
Cheers, this PR just saved us from what would have been a confusing day!
I've upgraded to React v16.3.2 and am seeing a similar error:
It's referencing a similar area of the React codebase, without a null check:
Please file a new issue with a reproducing case. Thanks.
To everyone who "+1"s the previous comment: sorry, but this doesn't help us solve the issue at all.
If you're seeing this after upgrading both react
and react-dom
to 16.3.2 or higher, please file a new issue with a minimal reproducing case extracted from your project. This will be very helpful to everyone, and we'll be able to quickly diagnose and fix this.
Most helpful comment
I've upgraded to React v16.3.2 and am seeing a similar error:
It's referencing a similar area of the React codebase, without a null check: