node.getComponent极低概率报错了,是啥原因呢?

报错信息如下:

Uncaught (in promise) TypeError: Cannot read property ‘length’ of null
at findComponent (base-node.js:58)
at cc_Node.getComponent (base-node.js:763)
at MainGroup.js:41

有人遇过吗?概率非常低非常低会发生这个情况吧。
MainGroup.js 是我项目中的代码,只是调用了以下代码,也是报错的代码getComponent的位置:

this._mainPageNode.getComponent(MainPage).initialize();

@jare @panda 大佬有空看一下吗?

引擎版本1.10.1

经过群里大神指点,貌似找到原因了。

this._mainPageNode此结点,此时可能已经被销毁。所以才会出这个bug。

说下为啥极低概率呢:是因为我逻辑业务是按照正常流程,请求网络接口,再初始化:this._mainPageNode.getComponent(MainPage).initialize();,

可能接口响应过慢,然后那个结点已经被销毁了。

1赞

…我也出现了,解决方案是什么

判断节点是否有效。。。。

还真是…谢谢哥们