preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

Null check missing in AsyncComponent.getPreviousSibling()

Open sparrowhawk-ea opened this issue 1 year ago • 2 comments

  • [ ] Check if updating to the latest Preact version resolves the issue

Describe the bug Uncaught TypeError: Cannot read properties of null (reading 'type') at getPreviousSibling (async.js?7a7b:8:1) at getPreviousSibling (async.js?7a7b:19:1) at getPreviousSibling (async.js?7a7b:23:1) at getPreviousSibling (async.js?7a7b:23:1) at AsyncComponent.render (async.js?7a7b:48:1)

To Reproduce Unfortunately, this is part of a large app and it is not easy to isolate a sample. Luckily, this is a simple null-check error with an easy fix.

Replace if (typeof vnode.type === 'string') return null;

With if (!vnode || typeof vnode.type === 'string') return null;

Since a recursive call is sending a null vnode.

Expected behavior Page should re-render on a setState but the above error occurs.

sparrowhawk-ea avatar Jul 30 '22 06:07 sparrowhawk-ea

That doesn't seem to be part of our codebase 😅

EDIT: ah I found it, this needs to go to to the Preact CLI repo https://github.com/preactjs/preact-cli/blob/master/packages/async-loader/async.js#L6

JoviDeCroock avatar Jul 30 '22 07:07 JoviDeCroock

Thanks! Want to write up a PR fixing this?

Reminded me of #1424 which looks to be the same issue.

rschristian avatar Jul 30 '22 08:07 rschristian