Gulp 的神奇 BUG

年初 1 月多时我的博客访问出了问题

大概在年初 1 月多时被友人提醒了我的博客访问可能出了问题,后半信半疑地在隐私模式打开博客确实发现了一些问题,再拿去 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

如下————

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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...
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
最后更新于 2021-10-24 22:35