vnode.type TypeError fixed #1537
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
typeof vnode.type will throw an Execption if vnode being
null. A simple truthy check fixes the issue.It's a bug fix. related to async-loader.
Did you add tests for your changes? No
Summary

In some circumstances vnode may become null, and trying to access a property on that will rise a TypeError exception. here is a screenshot of the exception:
This rare issue happened in a workplace repo, hence I can't provide you the code; but If you guys think It is absolutely necessary to have a look by yourself, I can try to reproduce it in new repository ( I'd actually tried once, but it wasn't successful. )
Does this PR introduce a breaking change?
No breaking changes.
Other information
Please paste the results of
preact infohere.Environment Info:
System:
OS: Windows 10 10.0.18362
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 14.15.4 - C:\Program Files\nodejs\node.EXE
Yarn: 1.21.1 - D:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.10 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 88.0.4324.146
Edge: Spartan (44.18362.449.0)
npmPackages:
preact: ^10.3.2 => 10.5.7
preact-cli: ^3.0.0 => 3.0.3
preact-render-to-string: ^5.1.4 => 5.1.12
preact-router: ^3.2.1 => 3.2.1