BuIlDaLiBlE/BetterHI3Launcher

Hi3Helper.Http error after resuming update download

MorganTwoZero opened this issue · 3 comments

Got an error after i tried to unpause downloading update of the game.
Same after restarting launcher, restarting PC, with and without VPN, with Hoyoverse server and Hi3mirror.

To Reproduce
Steps to reproduce the behavior:

  1. Start downloading update of the game
  2. Pause download
  3. Unpause download

Expected behavior
Successfully resume downloading of the update.

Log

BetterHI3Launcher v1.4.20230111.0
Working directory: D:\Games\Honkai Impact 3rd glb\
OS version: Windows 11 Pro (Version 21H2, Build 22000.1335)
OS language: en-US
Launcher language: en (autodetect)
Using server: Global
Using mirror: HoYoverse
Checking for game update...
Game version: 6.2.0
Game directory: D:\Games\Honkai Impact 3rd glb\Games
The game requires an update!
Starting to download game archive: BH3_v6.3.0_c923000a5a31.7z (https://d2wztyirwsuyyo.cloudfront.net/ptpublic/bh3_global/20230109172630_NRBvwa9qTB4EUXIz/BH3_v6.3.0_c923000a5a31.7z)
Download paused
Download resumed
Download paused
Download resumed
ERROR: Failed to download the game:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Hi3Helper.Http.Http.<InitializeMultiSession>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Hi3Helper.Http.Http.<Download>d__54.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at BetterHI3Launcher.MainWindow.<DownloadPauseButton_Click>d__59.MoveNext()

Thank you for reporting this issue.

As per my investigation, this was caused by the download checks while looking into some file chunks that had already been completed. The Session initialization didn't check if the chunk file was completely downloaded and instead skipped to IsSetResponseSuccess while also having false as its value. Then while the initializer tried to call the throw, instead it can't see the session.SessionResponse.StatusCode as it's now a null. In this part, the throw gives another throw to be sent as NullReferenceException.

In this neon-nyan/Hi3Helper.Http@483090a commit, I've wrote another check before IsSetResponseSuccess check to ensure if the size of the existing chunk is the same as an expected chunk, then it will skip it and go to the next Session initialization.

This commit neon-nyan/Hi3Helper.Http@60aae49 also fixes a bug when some of the chunks are getting skipped, then set the StartOffset with the next value for the next Session initialization.

At this moment, @BuIlDaLiBlE will update the submodule including those fixes and hope there will be another update release for BetterHi3Launcher to fix this issue.

I've released v1.4.20230113.0, please check if it works as expected now, if possible.

I wasn't able to replicate the problem in the new release, so i think it's safe to mark as solved.