Closed F1462900874 closed 2 years ago
你的镜像地址配置了腾讯的镜像,我们并未知晓其是否支持 CIPD 的获取,请向对应的镜像维护人员确认,谢谢。
@F1462900874 谢谢反馈,腾讯云镜像可能不在我们的“服务范围”之内 ;-)
如果不是在腾讯云内网使用,我们建议你使用我们的 flutter-io.cn
中国镜像或者使用清华 TUNA 的镜像,虽然腾讯云的镜像脚本来自 TUNA (*根据过去的经验,不确定现在是如何),但是我们和 TUNA 有合作——TUNA 的镜像配备了完善的 404 回源 flutter-io.cn
中国镜像的策略,因此应该会相对在访问的时候 Storage 有比较稳定的体验。
如果是需要在腾讯云内网或者使用腾讯云镜像是刚需的话,请根据我们的 镜像页面 的内容联系腾讯云镜像的维护者,如果腾讯云镜像未来修复了这个问题,也欢迎回来告诉我们。
@chenglu 好,请问下,如何验证腾讯云的CIPD获取是否正常? 以及tuna的404回源具体是怎么配置的?如果我司的私有源也计划支持flutter的话,需要做什么配置?
Tuna 镜像 404 回源思路是,前端的 nginx 服务器设定:如果遇到 404,就尝试:
https://mirrors.tuna.tsinghua.edu.cn/flutter/cdn-monitor-for-qiniu/1-1.gif
-- 这是之前我们合作共同在 tuna 建立镜像的时候设定的,关于回源中国镜像可用性检测的 URLhttps://mirrors.tuna.tsinghua.edu.cn/flutter/flutter_infra_release/cipd/flutter/web/canvaskit_bundle/+/yrsfF-vTvu4jzBBm1o6tDl70dky-l4G29Dnj75UvRDgC
-- 由于 cipd 是后期加入的,所以在 cipd 上应该是采取了这个策略具体配置方法应该是一些 nginx 反向代理处理 301、404 时候的常用配置,这里就不多赘述了。
腾讯云对 cipd 支持的验证方式,本 issue 里的那个链接仍处于无法访问状态,可能就代表这个问题腾讯云仍未修复。
不知道是否回答了你的问题,有任何问题请再随时沟通哈,谢谢~ cc/ @89ao
谢谢 @chenglu 进一步探讨一下,这里的404回源思路,是指以下哪种方式呢? A:
error_page 404 = https://mirrors.tuna.tsinghua.edu.cn/flutter/cdn-monitor-for-qiniu/1-1.gif
error_page 301 = https://mirrors.tuna.tsinghua.edu.cn/flutter/flutter_infra_release/cipd/flutter/web/canvaskit_bundle/+/yrsfF-vTvu4jzBBm1o6tDl70dky-l4G29Dnj75UvRDgC
B:
proxy_next_upstream error timeout http_404;
简单搜了一下,proxy_next_upstream
好像是适用于动态选择多台 upstream 的情况,看起来更像是第一种,error 404 的时候做别的操作。
nginx 可以设定捕获错误 proxy_intercept_errors on;
,然后你可以将收到的 404 错误 301 到访问中国镜像,如果中国镜像也是 404,那才是「真的」 404,或者也有中国镜像没有 cover 到的内容,届时应该会有反馈我们就会立刻处理,比如之前 cipd 以及 pub-package 更换 bucket 的时候。
换句话说,404 回源指的是,当你的 镜像服务器 在获取上游资源碰到 404 的时候,策略 1)301 跳转到中国镜像;策略 2)重新修改上游为中国镜像再次尝试获取资源,如果获取到内容就返回给用户,如果还是 404,再返回给用户 404。
这是因为不同的镜像获取上游资源的方式不同,有可能上游进行了修改而镜像还没有来记得跟进镜像策略,这个时候可能就会出现用户访问的时候 404,因此 Flutter 镜像配置完善的「404 回源」是非常必要的。
希望解答了你的问题,谢谢!
@chenglu 感谢答复:
上方的 error_page 404 = https://mirrors.tuna.tsinghua.edu.cn/flutter/cdn-monitor-for-qiniu/1-1.gif 我理解是404到固定的url上。
那么error_page 301 = https://mirrors.tuna.tsinghua.edu.cn/flutter/flutter_infra_release/cipd/flutter/web/canvaskit_bundle/+/yrsfF-vTvu4jzBBm1o6tDl70dky-l4G29Dnj75UvRDgC 这个后面的url是固定写死的,还是需要写表达式转换呢?(根据不同包跳转到不同url?)
另外,我这边配置完成之后有办法可以测试吗?是否我访问https://domain.to.repo/flutter/NoneExistPak/ 能跳转到1-1.gif即人为成功?
我之前提到过:
404 回源指的是,当你的 镜像服务器 在获取上游资源碰到 404 的时候,策略 1)301 跳转到中国镜像;策略 2)重新修改上游为中国镜像再次尝试获取资源,如果获取到内容就返回给用户,如果还是 404,再返回给用户 404。
因此这个逻辑实现起来建议是,如果遇到 404,proxy_pass 变成中国镜像重新请求,请求成功加入缓存,如果还是 404,就 301 到中国镜像去。
另外请谅解,对于镜像的问题,我们只能对一些通用的问题做回应和解答,具体的网络环境比较复杂,需要自行做更多探索和构建哈,谢谢理解和支持!
收到,非常感谢!
问题镜像 URL
Downloading CanvasKit failed导致项目无法启动
错误内容截图或 log
Failed to download https://mirrors.cloud.tencent.com/flutter/flutter_infra_release/cipd/flutter/web/canvaskit_bundle/+/yrsfF-vTvu4jzBBm1o6tDl70dky-l4G29Dnj75UvRDgC. Ensure you have network connectivity and then try again.
pubspec.yaml
网络环境
No response
flutter doctor -v