Gulp 的神奇 BUG

Author Avatar
黯梦萦辰 2月 14, 2020
  • 在其它设备中阅读本文章
 1.9k字  大约10分钟  代码4

大概在年初一月多时被友人提醒了我的博客访问可能出了问题,后半信半疑地在隐私模式打开博客确实发现了一些问题,再拿去 Google insight 也出现了一样的问题,这才开始了 Bug 的分析。

异常如下:

check console,没有重大警告或者错误。

check network,无异常。

Cloudflare proxy 已关闭

当时近期的改动便是 Gulp。将 node_modules 重装一遍异常页面依旧。

刚开始使用 Gulp 时,build 网页是可以正常访问的,故之后的每次 build 便懒得去检查页面的是否正常显示。

从 gulpfile.js 中逐一分析排查出了 Bug 的位置,是在 compressJs。

再将有执行 compressJs 的和没有执行的分别保存为 html 并 diff

神奇之处出现了————

这两个文件除了端口号不同,其他都一致。

端口号的不同是由于使用 Brackets 在 Chrome 动态调试的结果。

懵了一圈后去命令行找了找 gulp build 的输出 log

如下————

INFO  178 files generated in 1.9 s
[18:46:46] Finished 'generate' after 3.56 s
[18:46:46] Starting 'compressHtml'...
[18:46:46] Compress HTML: public/404.html
[18:46:46] Compress HTML: public/index.html
[18:46:46] Compress HTML: public/laycomment.html
[18:46:47] Compress HTML: public/about/index.html
[18:46:47] Compress HTML: public/archives/2019-nian-du-zong-jie.html
[18:46:47] Compress HTML: public/archives/bu-shu-gitalk-chu-xian-de-keng.html
[18:46:47] Compress HTML: public/archives/gulp-de-shen-qi-bug.html
[18:46:47] Compress HTML: public/archives/how-to-walk-tiny-little-life.html
[18:46:47] Compress HTML: public/archives/index.html
[18:46:47] Compress HTML: public/archives/lu-nai-samfree.html
[18:46:48] Compress HTML: public/archives/material-geng-duo-xin-xi.html
[18:46:48] Compress HTML: public/archives/our-end-of-the-world.html
[18:46:48] Compress HTML: public/archives/tzmcm-bi-sai-guo-cheng-jie-guo.html
[18:46:48] Compress HTML: public/archives/xian-chong-du-bao-zha-ba.html
[18:46:48] Compress HTML: public/archives/yin-se-feng-jing.html
[18:46:48] Compress HTML: public/archives/zai-html-zhong-yong-js-cao-zuo-json.html
[18:46:48] Compress HTML: public/categories/index.html
[18:46:48] Compress HTML: public/links/index.html
[18:46:49] Compress HTML: public/kami/index.html
[18:46:49] Compress HTML: public/timeline/index.html
[18:46:49] Compress HTML: public/archives/2020/index.html
[18:46:49] Compress HTML: public/archives/2019/index.html
[18:46:49] Compress HTML: public/categories/日常/index.html
[18:46:49] Compress HTML: public/categories/代码/index.html
[18:46:49] Compress HTML: public/categories/知识/index.html
[18:46:49] Compress HTML: public/categories/随想/index.html
[18:46:49] Compress HTML: public/page/3/index.html
[18:46:50] Compress HTML: public/page/2/index.html
[18:46:50] Compress HTML: public/archives/2020/01/index.html
[18:46:50] Compress HTML: public/archives/2020/02/index.html
[18:46:50] Compress HTML: public/archives/2020/03/index.html
[18:46:50] Compress HTML: public/archives/2019/09/index.html
[18:46:50] Compress HTML: public/archives/2019/07/index.html
[18:46:50] Compress HTML: public/archives/2019/10/index.html
[18:46:50] Compress HTML: public/archives/2019/11/index.html
[18:46:50] Compress HTML: public/archives/page/3/index.html
[18:46:50] Compress HTML: public/archives/page/2/index.html
[18:46:50] Compress HTML: public/archives/2019/page/2/index.html
[18:46:51] Compress HTML: 38 items
[18:46:51] Finished 'compressHtml' after 4.69 s
[18:46:51] Starting 'compressCss'...
[18:46:51] Compress CSS: public/css/disqus-proxy.css
[18:46:51] Compress CSS: public/css/duoshuo.css
[18:46:51] Compress CSS: public/css/gitalk.css
[18:46:51] Compress CSS: public/css/ie-blocker.css
[18:46:51] Compress CSS: public/css/material-icons.css
[18:46:51] Compress CSS: public/css/material.css
[18:46:51] Compress CSS: public/css/prettify.css
[18:46:51] Compress CSS: public/css/style.css
[18:46:51] Compress CSS: public/css/uc.css
[18:46:51] Compress CSS: 9 items
[18:46:51] Finished 'compressCss' after 948 ms
[18:46:51] Starting 'compressJs'...
[18:46:52] Compress JS: public/js/MathJax.js
[18:46:53] Compress JS: public/js/Valine.min.js
[18:46:54] Compress JS: public/js/clicklove.js
[18:46:54] Compress JS: public/js/funnytitle.js
[18:46:54] Compress JS: public/js/gitalk.min.js
[18:46:56] Compress JS: public/js/hanabi-browser-bundle.js
[18:46:57] Compress JS: public/js/ie-blocker.en.js
[18:46:57] Compress JS: public/js/ie-blocker.zhCN.js
[18:46:57] Compress JS: public/js/jquery.min.js
[18:46:58] Compress JS: public/js/js.js
[18:46:59] Compress JS: public/js/js.min.js
[18:46:59] Compress JS: public/js/lazyload.min.js
[18:47:00] Compress JS: public/js/lsloader.js
[18:47:00] Compress JS: public/js/lsloader.min.js
[18:47:00] Compress JS: public/js/md5.min.js
[18:47:00] Compress JS: public/js/nprogress.js
[18:47:00] Compress JS: public/js/prettify.min.js
[18:47:00] Compress JS: public/js/queue.js
[18:47:00] Compress JS: public/js/queue.min.js
[18:47:00] Compress JS: public/js/smoothscroll.js
[18:47:00] Compress JS: public/js/gallery/gallery.js
[18:47:00] Compress JS: 21 items
[18:47:01] Finished 'compressJs' after 9.22 s
[18:47:01] Starting 'deploy'...
INFO  Deploying: git
INFO  Setting up Git deployment...
INFO  178 files generated in 2.71 s
[19:17:09] Finished 'generate' after 5.07 s
[19:17:09] Starting 'compressHtml'...
[19:17:09] Compress HTML: public/404.html
[19:17:09] Compress HTML: public/index.html
[19:17:09] Compress HTML: public/laycomment.html
[19:17:09] Compress HTML: public/about/index.html
[19:17:10] Compress HTML: public/categories/index.html
[19:17:10] Compress HTML: public/archives/2019-nian-du-zong-jie.html
[19:17:10] Compress HTML: public/archives/bu-shu-gitalk-chu-xian-de-keng.html
[19:17:10] Compress HTML: public/archives/gulp-de-shen-qi-bug.html
[19:17:10] Compress HTML: public/archives/how-to-walk-tiny-little-life.html
[19:17:11] Compress HTML: public/archives/index.html
[19:17:11] Compress HTML: public/archives/lu-nai-samfree.html
[19:17:11] Compress HTML: public/archives/material-geng-duo-xin-xi.html
[19:17:11] Compress HTML: public/archives/our-end-of-the-world.html
[19:17:11] Compress HTML: public/archives/tzmcm-bi-sai-guo-cheng-jie-guo.html
[19:17:11] Compress HTML: public/archives/xian-chong-du-bao-zha-ba.html
[19:17:12] Compress HTML: public/archives/yin-se-feng-jing.html
[19:17:12] Compress HTML: public/archives/zai-html-zhong-yong-js-cao-zuo-json.html
[19:17:12] Compress HTML: public/kami/index.html
[19:17:12] Compress HTML: public/links/index.html
[19:17:12] Compress HTML: public/timeline/index.html
[19:17:13] Compress HTML: public/categories/日常/index.html
[19:17:13] Compress HTML: public/categories/代码/index.html
[19:17:13] Compress HTML: public/categories/随想/index.html
[19:17:13] Compress HTML: public/categories/知识/index.html
[19:17:13] Compress HTML: public/archives/2019/index.html
[19:17:13] Compress HTML: public/archives/2020/index.html
[19:17:13] Compress HTML: public/page/2/index.html
[19:17:13] Compress HTML: public/page/3/index.html
[19:17:14] Compress HTML: public/archives/2019/07/index.html
[19:17:14] Compress HTML: public/archives/page/3/index.html
[19:17:14] Compress HTML: public/archives/2019/09/index.html
[19:17:14] Compress HTML: public/archives/2019/10/index.html
[19:17:14] Compress HTML: public/archives/page/2/index.html
[19:17:14] Compress HTML: public/archives/2020/01/index.html
[19:17:14] Compress HTML: public/archives/2019/11/index.html
[19:17:14] Compress HTML: public/archives/2020/02/index.html
[19:17:15] Compress HTML: public/archives/2020/03/index.html
[19:17:15] Compress HTML: public/archives/2019/page/2/index.html
[19:17:15] Compress HTML: 38 items
[19:17:15] Finished 'compressHtml' after 6.32 s
[19:17:15] Starting 'compressCss'...
[19:17:15] Compress CSS: public/css/disqus-proxy.css
[19:17:15] Compress CSS: public/css/duoshuo.css
[19:17:15] Compress CSS: public/css/gitalk.css
[19:17:15] Compress CSS: public/css/ie-blocker.css
[19:17:15] Compress CSS: public/css/material-icons.css
[19:17:15] Compress CSS: public/css/material.css
[19:17:16] Compress CSS: public/css/prettify.css
[19:17:16] Compress CSS: public/css/style.css
[19:17:16] Compress CSS: public/css/uc.css
[19:17:16] Compress CSS: 9 items
[19:17:16] Finished 'compressCss' after 1.08 s
[19:17:16] Starting 'deploy'...
INFO  Deploying: git
INFO  Clearing .deploy_git folder...

两次的 build 是不一样的,但是生成的文件却相同。

相同的文件也由于不同的 build 产生了不同的结果。

问题尚未解决。因为没时间就先把记录留在这里。
若在别处得到了答案,我会在第一时间补充博客。

After Day

这篇文章原计划是 2 月初便要写的,咕了一段时间后连着 3 月那篇闲聊发了出来。

日期就随便糊了个单身狗的日子(简称狗日的)

顺便封面也是可爱的狗狗(是幼犬酱啦~)

疾病盛行,小心出行。

版权声明:CC BY-NC-SA 4.0 License
本文链接:https://blog.tinyume.com/archives/gulp-de-shen-qi-bug.html