0x01 症状
症状为Slack Mac客户端无限转圈,刷新无效。但是网页版登录正常。
0x02 收集
由于Slack的Mac客户端关闭了右键查看各种信息的功能。首先要做的就是拿到更多信息辅助判断。一般程序都会写日志,日志就会打开文件句柄,然后通过活动监视器去看到底哪个文件被打开了。
经过一番查找,的确发现了一个像是日志的文件句柄,文件名为/Users/[用户名]/Library/Containers/com.tinyspeck.slackmacgap/Data/Library/Application Support/Slack/logs/webapp-T03UMNDS2-console.log
。经过tail发现的确是日志,于是刷新页面,观察日志输出:
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 |
info: Oct-23 19:18:02.803 [FOCUS-EVENT] Window blurred error: Oct-23 19:18:04.665 SOCKET-MANAGER (*********) Closing socket because we spent 60000 ms in prov_connected state; giving up error: Oct-23 19:18:04.665 SOCKET-MANAGER (*********) Closing socket because #4107: client state machine got stuck info: Oct-23 19:18:04.666 [SOCKET-MANAGER] (*********) Changing from prov_connected to error info: Oct-23 19:18:04.666 [SOCKET-MANAGER] (*********) will stay in error state for up to 10000 ms info: 2018/10/23 19:18:04.668 Stacktrace: ↴ at e (https://a.slack-edge.com/bv1-5/rollup-core_required_ts.9099665e649e19373615.min.js:1:111078) at https://a.slack-edge.com/bv1-5/modern.vendor.e84f3e2e39b3bf41ae8c.min.js:1:22716 at e (https://a.slack-edge.com/bv1-5/modern.vendor.e84f3e2e39b3bf41ae8c.min.js:1:852804) at e (https://a.slack-edge.com/bv1-5/modern.vendor.e84f3e2e39b3bf41ae8c.min.js:1:855162) at https://a.slack-edge.com/bv1-5/modern.vendor.e84f3e2e39b3bf41ae8c.min.js:1:857147 info: Oct-23 19:18:04.669 [SOCKET-MANAGER] (*********) Changing from error to wait_for_rate_limit info: Oct-23 19:18:04.669 [SOCKET-MANAGER] (*********) will stay in wait_for_rate_limit state for up to 120000 ms info: Oct-23 19:18:04.670 [SOCKET-MANAGER] (*********) backing off: will wait for 382 ms info: Oct-23 19:18:05.053 [SOCKET-MANAGER] (*********) Changing from wait_for_rate_limit to connect info: Oct-23 19:18:05.054 [SOCKET-MANAGER] (*********) will stay in connect state for up to 10000 ms info: Oct-23 19:18:05.054 [SOCKET-MANAGER] (*********) Changing from connect to checking_fast_reconnect info: Oct-23 19:18:05.055 [SOCKET-MANAGER] (*********) will stay in checking_fast_reconnect state for up to 60000 ms info: Oct-23 19:18:05.055 [SOCKET-MANAGER] (*********) Changing from checking_fast_reconnect to prov_connect info: Oct-23 19:18:05.055 [SOCKET-MANAGER] (*********) will stay in prov_connect state for up to 10000 ms info: Oct-23 19:18:05.056 [SOCKET-MANAGER] (*********) Changing from prov_connect to prov_connecting info: Oct-23 19:18:05.056 [SOCKET-MANAGER] (*********) will stay in prov_connecting state for up to 35000 ms info: Oct-23 19:18:07.228 [SOCKET-MANAGER] (*********) Changing from prov_connecting to prov_connected info: Oct-23 19:18:07.228 [SOCKET-MANAGER] (*********) will stay in prov_connected state for up to 60000 ms info: Oct-23 19:18:07.230 [INFO] Got start data from Socket Manager; hydrating it error: Oct-23 19:19:07.230 SOCKET-MANAGER (*********) Closing socket because we spent 60000 ms in prov_connected state; giving up error: Oct-23 19:19:07.231 SOCKET-MANAGER (*********) Closing socket because #4107: client state machine got stuck info: Oct-23 19:19:07.232 [SOCKET-MANAGER] (*********) Changing from prov_connected to error info: Oct-23 19:19:07.232 [SOCKET-MANAGER] (*********) will stay in error state for up to 10000 ms info: 2018/10/23 19:19:07.233 Stacktrace: ↴ at e (https://a.slack-edge.com/bv1-5/rollup-core_required_ts.9099665e649e19373615.min.js:1:111078) at https://a.slack-edge.com/bv1-5/modern.vendor.e84f3e2e39b3bf41ae8c.min.js:1:22716 at e (https://a.slack-edge.com/bv1-5/modern.vendor.e84f3e2e39b3bf41ae8c.min.js:1:852804) at e (https://a.slack-edge.com/bv1-5/modern.vendor.e84f3e2e39b3bf41ae8c.min.js:1:855162) at https://a.slack-edge.com/bv1-5/modern.vendor.e84f3e2e39b3bf41ae8c.min.js:1:857147 info: Oct-23 19:19:07.234 [SOCKET-MANAGER] (*********) Changing from error to wait_for_rate_limit info: Oct-23 19:19:07.234 [SOCKET-MANAGER] (*********) will stay in wait_for_rate_limit state for up to 120000 ms info: Oct-23 19:19:07.235 [SOCKET-MANAGER] (*********) backing off: will wait for 1110 ms info: Oct-23 19:19:08.346 [SOCKET-MANAGER] (*********) Changing from wait_for_rate_limit to connect info: Oct-23 19:19:08.347 [SOCKET-MANAGER] (*********) will stay in connect state for up to 10000 ms info: Oct-23 19:19:08.348 [SOCKET-MANAGER] (*********) Changing from connect to checking_fast_reconnect info: Oct-23 19:19:08.348 [SOCKET-MANAGER] (*********) will stay in checking_fast_reconnect state for up to 60000 ms info: Oct-23 19:19:08.349 [SOCKET-MANAGER] (*********) Changing from checking_fast_reconnect to prov_connect info: Oct-23 19:19:08.349 [SOCKET-MANAGER] (*********) will stay in prov_connect state for up to 10000 ms info: Oct-23 19:19:08.349 [SOCKET-MANAGER] (*********) Changing from prov_connect to prov_connecting info: Oct-23 19:19:08.349 [SOCKET-MANAGER] (*********) will stay in prov_connecting state for up to 35000 ms info: Oct-23 19:19:10.071 [SOCKET-MANAGER] (*********) Changing from prov_connecting to prov_connected info: Oct-23 19:19:10.071 [SOCKET-MANAGER] (*********) will stay in prov_connected state for up to 60000 ms info: Oct-23 19:19:10.073 [INFO] Got start data from Socket Manager; hydrating it |
看起来应该是某些资源执行的时候有问题。比如执行这个文件https://a.slack-edge.com/bv1-5/rollup-core_required_ts.9099665e649e19373615.min.js
遇到了问题。我把这个文件放到浏览器中访问,看起来资源是完整的。
0x03 分析
一般而言这种情况下多半是缓存出了问题。由于缓存了不完整的资源,不会请求新资源也不能正常加载。所以接下来尝试找到缓存并清理缓存
0x04 解决
Slack的文件分布在各处,不仔细找很难找到缓存在哪。不过也有一个比较快的方式。缓存一般都是文件,是文件就要被打开,就有文件句柄,就能通过活动监视器找到。于是找了一番,找到了一个名字里面带Cache的路径/Users/[用户名]/Library/Containers/com.tinyspeck.slackmacgap/Data/Library/Application Support/Slack/Cache
进入,发现了一堆f_*****
的文件,rm *
删之。
然后重启Slack,问题解决~
0x05 回顾
看起来应当是Slack使用的Electron在处理缓存文件时存在问题。如果缓存文件不完整或者被修改,没有过超时期,依然会被加载。估计也是,因为缓存头只有ETag标签,并没有哈希值,所以被修改也是比较难发现。对于缓存的完整性问题,需要有更好的方案。