Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publisher-Electron-Release-Server: Asset Upload fails with 400 Bad Request (file size seems to be missing) #2087

Closed
3 tasks done
monsterkrampe opened this issue Dec 14, 2020 · 5 comments · Fixed by #2706
Closed
3 tasks done
Labels

Comments

@monsterkrampe
Copy link
Contributor

monsterkrampe commented Dec 14, 2020

Preflight Checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Issue Details

  • Electron Forge Version:
    • 6.0.0-beta.54
  • Electron Version:
    • 10.1.0
  • Operating System:
    • Arch Linux
  • Last Known Working Electron Forge version::
    • N/A

Expected Behavior

I setup an electron release server using the docker image from docker hub https://hub.docker.com/r/eoskin/electron-release-server. Now I tried publishing packages using the built-in electron-forge publisher.
I would expect that the upload works out of the box.

Actual Behavior

The server is throwing a 400 Bad Request when uploading the assets.
The server side validation fails because the file size is missing. I dug into the packages used on the server side quite a bit but I could not find an issue. Also the upload in the web interface works as expected.

According to the form-data library that is used in the electron forge publisher, it seems to be required that the file size is set explicitly using knownLength. They have a note in their readme saying: "getLengthSync() method DOESN'T calculate length for streams, use knownLength options as workaround." There is also an issue that seems to be related: form-data/form-data#426
This is currently not done in the Publisher-Electron-Release-Server package.

To Reproduce

Setup an electron-release-server using the docker image and try publishing packages using electron-forge (I guess it should happen independent of the platform, etc., though I only tested it for linux zips right now.)

Additional Information

I'm actually a little puzzled that there is no issue created regarding that yet, since I cannot imagine that I am the only one having this problem. Sorry if I just overlooked something.

Nevertheless, I will submit a PR containing a workaround using the knownLength option, since this seems to be the way to go for now according to the form-data package. I also tested this out right now and it indeed fixes the issue for me.

monsterkrampe added a commit to monsterkrampe/electron-forge that referenced this issue Dec 14, 2020
@monsterkrampe
Copy link
Contributor Author

The missing knownLength option may also affect other publishers as well but I did not check that.

@MarshallOfSound
Copy link
Member

Valid fix here #2088 but in conflict, if someone rebases it can land

@monsterkrampe
Copy link
Contributor Author

Will do in the next days, thx @MarshallOfSound :)

monsterkrampe added a commit to monsterkrampe/electron-forge that referenced this issue Feb 5, 2022
monsterkrampe added a commit to monsterkrampe/electron-forge that referenced this issue Feb 5, 2022
monsterkrampe added a commit to monsterkrampe/electron-forge that referenced this issue Mar 2, 2022
VerteDinde pushed a commit that referenced this issue Apr 19, 2022
@VerteDinde
Copy link
Member

Merged - thanks again for the bug report and fix, @monsterkrampe! 🙇‍♀️

@monsterkrampe
Copy link
Contributor Author

You're very welcome :)

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