Skip to content

Cannot read property 'return' of null #12449

Closed
@jquense

Description

@jquense

Running into a strange issue that i cannot reproduce, it happens when running tests in Karma using 16.3.0-alpha.3

image

The issue is here:

if (nextUnitOfWork === null) {
// This is a fatal error.
didFatal = true;
onUncaughtError(thrownValue);
break;
}
if (__DEV__ && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
const failedUnitOfWork = nextUnitOfWork;
replayUnitOfWork(failedUnitOfWork, isAsync);
}
const sourceFiber: Fiber = nextUnitOfWork;
let returnFiber = sourceFiber.return;

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions