Skip to content

Conversation

@beyondkmp
Copy link
Contributor

fix #9270

@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2025

🦋 Changeset detected

Latest commit: e35c4aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
electron-updater Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@beyondkmp beyondkmp changed the title fix: Cannot download differentially because of space in range fix: cannot download differentially because of space in range Sep 15, 2025
@beyondkmp beyondkmp requested a review from mmaietta September 15, 2025 03:35
@beyondkmp
Copy link
Contributor Author

@mmaietta differentialUpdateTest keeps failing, and it seems the test server no longer supports this configuration.

@mmaietta
Copy link
Collaborator

the test server no longer supports this configuration.

What do you mean by this? If the current test server doesn't accept the new differential range format, doesn't that signify this change is not backward compatible?

@cubimon
Copy link

cubimon commented Sep 24, 2025

I tried to understand how differentialUpdateTest.ts works, but I have no idea how it works and where exactly it fails and why it is not compatible

@beyondkmp
Copy link
Contributor Author

I haven't found where this update server is yet. I haven't found it.

@beyondkmp
Copy link
Contributor Author

@mmaietta I've found the reason for the UT failure; it's because we used the 'ran' server(https://github.com/m3ng9i/ran/tree/master/server), which doesn't support ranges without spaces. It seems the server didn't handle this case properly. According to RFC 7233, it should support both cases: with and without spaces.

@mmaietta
Copy link
Collaborator

Do we need to update ran then for supporting both formats per RFC 7233? Will that suffice or do we need a new command-line server for executing this workflow (and a few others that use ran)

Copilot AI review requested due to automatic review settings December 21, 2025 04:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix issue #9270 related to differential downloads failing due to spaces in HTTP Range headers. The change removes the trailing space after commas when constructing multi-part range request headers.

Key Changes:

  • Removed trailing space from range string construction (changing ", " to "," in the loop that builds the ranges string)

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/electron-updater/src/differentialDownloader/multipleRangeDownloader.ts Modified range header construction to remove trailing space after comma
.changeset/hungry-eagles-explain.md Added changeset documenting the fix

Critical Issue Found: The fix is incomplete and introduces a new bug. While line 49 correctly removes the trailing space, line 93 (not shown in the diff but visible in the surrounding code) still uses ranges.substring(0, ranges.length - 2) to trim the final comma and space. With this change, only the comma remains at the end, so the substring should use ranges.length - 1 instead. This will cause the last digit of the final range's end value to be truncated, resulting in malformed HTTP Range headers.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const task = options.tasks[i]
if (task.kind === OperationKind.DOWNLOAD) {
ranges += `${task.start}-${task.end - 1}, `
ranges += `${task.start}-${task.end - 1},`
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is incomplete. While the trailing space has been removed from line 49, line 93 still uses ranges.substring(0, ranges.length - 2) which assumes both a comma and a space need to be removed. With this change, only the comma remains, so line 93 should use ranges.length - 1 instead.

Currently, this will result in truncating the last digit of the final range's end value, leading to incorrect HTTP Range headers being sent to the server. For example, if the last range is "100-199", it would be sent as "bytes=100-19" instead of "bytes=100-199".

Copilot uses AI. Check for mistakes.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a valid point and should be fixed, otherwise it will break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot download differentially

3 participants