使用电子更新程序时的 ERR_HTTP2_PROTOCOL_ERROR

问题描述

我正在尝试使用来自 github 的 repo 来测试电子更新程序。它开始检测更新可用,然后开始下载。但随着下载开始加快速度,此错误会在下载完全停止之前多次触发。有没有人遇到过这个错误

'错误:net::ERR_HTTP2_PROTOCOL_ERROR\n' + ' 在 SimpleURLLoaderWrapper 中。 (electron/js2c/browser_init.js:105:6497)\n' + ' 在 SimpleURLLoaderWrapper.emit (events.js:315:20)'

解决方法

将它与 autoUpdater 样板代码一起添加似乎对我有用(在 Windows 和 macOS 上尝试了两次):

app.commandLine.appendSwitch('disable-http2');
autoUpdater.requestHeaders = {'Cache-Control' : 'no-store,no-cache,must-revalidate,proxy-revalidate,max-age=0'};

来源:https://github.com/electron-userland/electron-builder/issues/4987

希望它也适合你。