assets-retry
assets-retry copied to clipboard
偶现情况: hookElement 出来的不是 Node,导致 appendChild 的时候出错。
I'm submitting a...
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
Current behavior
hookElement 出来的不是 Node,导致 appendChild 的时候出错。
{
"message":"Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.",
"name":"TypeError",
"stack":"TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.\n"
}
Expected behavior
能确保 hookElement 出来的一定是 Node.
Minimal reproduction of the problem with instructions
偶现情况,暂未找到原因
What is the motivation / use case for changing the behavior?
不会阻塞其他脚本的加载
Environment
Assets-retry version: 0.3.3
For Tooling issues:
- Browser version: Edge(103.0)
- Platform: Windows
Others:
- userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36 Edg/103.0.1264.37
@Nikaple 目前无法复现,所以想来这里问一下,出错的 appendChild 是 webpack 里的那个动态加载的 createElement('script')。经过 hookElement 之后这个元素的返回值是 hookedElement。
出错的
appendChild是webpack里的那个动态加载的createElement('script')。经过hookElement之后这个元素的返回值是hookedElement。
这是为了重试动态加载 JS 而执行的正常逻辑。
这是为了重试动态加载 JS 而执行的正常逻辑。
嗯嗯,我理解,不过根据报错,像是有某种情况 hook 失败了,导致的 Failed to execute 'appendChild' on 'Node'
所以需要你提供复现链接,或者定位到问题的原因,只提一个issue并不能解决问题
目前就是无法稳定复现,所以来这里提 issue 看看有没有啥头绪的,等找到稳定复现的情况再继续这个 issue 吧。
目前就是无法稳定复现,所以来这里提 issue 看看有没有啥头绪的,等找到稳定复现的情况再继续这个 issue 吧。
老哥,你解决了吗?我也遇到了这个问题。
老哥,你解决了吗?我也遇到了这个问题。
还没解决。
hi @Nikaple 我们找到了百分百复现的步骤,你这边最近会修复吗?
复现代码:
<script> var iframe = document.createElement('iframe'); iframe.src = 'about:blank'; document.body.appendChild(iframe); iframe.addEventListener('load', function() { // !!! NOTE: 这一行如果改成 var script = iframe.contentDocument.createElement('script'); 就不会有问题 var script = document.createElement('script'); script.src = 'https://example.com/your-script.js'; iframe.contentDocument.head.appendChild(script); }); </script>
@DillionZ @moecasts @WinneyFeng 有空可以尝试下 #103 是否解决问题:https://github.com/Nikaple/assets-retry/tree/fix/iframe/dist
@DillionZ @moecasts @WinneyFeng 有空可以尝试下 #103 是否解决问题:https://github.com/Nikaple/assets-retry/tree/fix/iframe/dist
hi @Nikaple 上一次提供的最小复现代码是fixed了,但是我这边的页面代码还是可以百分百复现,于是再给你提供一个最小复现代码:
<script> var iframe = document.createElement('iframe'); iframe.src = 'about:blank'; document.body.appendChild(iframe); var script = document.createElement('script'); script.src = '/assets/plugins/storehub-frontend-utils/frontend-utils.2.0.4.umd.production.min.js'; iframe.contentDocument.head.appendChild(script); </script>