Skip to content

Commit fe8bde3

Browse files
fix(desktop): Nightly update checks find the newest nightly past newer preview builds
electron-updater's GitHub provider looks for a prerelease of the selected channel only among the 10 entries of releases.atom. Preview builds published after the last nightly can fill that window, so a Nightly check failed with ERR_UPDATER_NO_PUBLISHED_VERSIONS. When the feed has no release on the selected prerelease channel, the patched provider now pages the REST releases list for the newest non-draft one. Fixes #35457 AI-assisted; verified with the tests and tools listed above.
1 parent 315b06c commit fe8bde3

2 files changed

Lines changed: 66 additions & 4 deletions

File tree

‎patches/[email protected]‎

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/out/electronHttpExecutor.js b/out/electronHttpExecutor.js
2-
index 0ae9e1126e1dc136977914ef1bfd46709fc9db1b..3932b6607ca41e6663aae001111c9b18594ed37a 100644
2+
index 0ae9e1126e1dc136977914ef1bfd46709fc9db1b..c298ffe7808c421c29e16f1e2ba8510f0cd31142 100644
33
--- a/out/electronHttpExecutor.js
44
+++ b/out/electronHttpExecutor.js
55
@@ -61,6 +61,35 @@ class ElectronHttpExecutor extends builder_util_runtime_1.HttpExecutor {
@@ -38,3 +38,65 @@ index 0ae9e1126e1dc136977914ef1bfd46709fc9db1b..3932b6607ca41e6663aae001111c9b18
3838
addRedirectHandlers(request, options, reject, redirectCount, handler) {
3939
request.on("redirect", (statusCode, method, redirectUrl) => {
4040
// no way to modify request options, abort old and make a new one
41+
diff --git a/out/providers/GitHubProvider.js b/out/providers/GitHubProvider.js
42+
index e768d24e7a957caf32a4b8ca6c68cb50eb5865ee..34a0759220c0cce052285204b2d14fdf0db905e5 100644
43+
--- a/out/providers/GitHubProvider.js
44+
+++ b/out/providers/GitHubProvider.js
45+
@@ -107,6 +107,12 @@ class GitHubProvider extends BaseGitHubProvider {
46+
catch (e) {
47+
throw (0, builder_util_runtime_1.newError)(`Cannot parse releases feed: ${e.stack || e.message},\nXML:\n${feedXml}`, "ERR_UPDATER_INVALID_RELEASE_FEED");
48+
}
49+
+ // The atom feed lists only the 10 newest releases, which other prereleases can fill.
50+
+ let apiRelease = null;
51+
+ if (tag == null && this.updater.allowPrerelease && this.updater.channel) {
52+
+ apiRelease = await this.getLatestChannelRelease(this.updater.channel, cancellationToken);
53+
+ tag = apiRelease === null ? null : apiRelease.tag_name;
54+
+ }
55+
if (tag == null) {
56+
throw (0, builder_util_runtime_1.newError)(`No published versions on GitHub`, "ERR_UPDATER_NO_PUBLISHED_VERSIONS");
57+
}
58+
@@ -144,6 +150,14 @@ class GitHubProvider extends BaseGitHubProvider {
59+
}
60+
}
61+
const result = (0, Provider_1.parseUpdateInfo)(rawData, channelFile, channelFileUrl);
62+
+ if (apiRelease !== null) {
63+
+ if (result.releaseName == null) {
64+
+ result.releaseName = apiRelease.name || apiRelease.tag_name;
65+
+ }
66+
+ if (result.releaseNotes == null) {
67+
+ result.releaseNotes = apiRelease.body || "";
68+
+ }
69+
+ }
70+
if (result.releaseName == null) {
71+
result.releaseName = latestRelease.elementValueOrEmpty("title");
72+
}
73+
@@ -155,6 +169,29 @@ class GitHubProvider extends BaseGitHubProvider {
74+
...result,
75+
};
76+
}
77+
+ async getLatestChannelRelease(channel, cancellationToken) {
78+
+ for (let page = 1; page <= 5; page++) {
79+
+ const url = new url_1.URL(`${this.computeGithubBasePath(`/repos/${this.options.owner}/${this.options.repo}/releases`)}?per_page=100&page=${page}`, this.baseApiUrl);
80+
+ const rawData = await this.httpRequest(url, { Accept: "application/vnd.github+json" }, cancellationToken);
81+
+ const releases = rawData == null ? [] : JSON.parse(rawData);
82+
+ if (!Array.isArray(releases)) {
83+
+ return null;
84+
+ }
85+
+ for (const release of releases) {
86+
+ if (release == null || release.draft || typeof release.tag_name !== "string" || !semver.valid(release.tag_name)) {
87+
+ continue;
88+
+ }
89+
+ const releaseChannel = semver.prerelease(release.tag_name);
90+
+ if (releaseChannel !== null && releaseChannel[0] === channel) {
91+
+ return release;
92+
+ }
93+
+ }
94+
+ if (releases.length < 100) {
95+
+ return null;
96+
+ }
97+
+ }
98+
+ return null;
99+
+ }
100+
async getLatestTagName(cancellationToken) {
101+
const options = this.options;
102+
// do not use API for GitHub to avoid limit, only for custom host or GitHub Enterprise

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)