Skip to content

Unable to view job logs gh run view --log #11059

Description

@ptorgalmath-gpsw

Describe the bug

Running gh run view --log --job #jobNumber results in failure for logs of bigger size. This issue also occurs when downloading logs archives via GitHub webpage for the workflow.

Affected version

gh version
gh version 2.74.0 (2025-05-29)
https://github.com/cli/cli/releases/tag/v2.74.0

Steps to reproduce the behavior

  1. Type this 'gh run view --log --job #jobNumber'
  2. The output 'failed to get run log: stream error: stream ID 1; CANCEL; received from peer'

Expected vs actual behavior

Error while trying to view logs for a job and the same issue occurs via GitHub.com as well, tried on chrome and safari. On safari after downloading for sometime I get 'The network connection is lost'. In some cases retrying the download archive works but CLI fails for specific jobs(I suspect it's to do with large log size). Log sizes are ~500MB for some workflows.

Activity

  1. babakks commented on Jun 12, 2025

    @babakks
    Member

    Thanks for reporting this, @ptorgalmath-gpsw! 🙏

    As you mentioned the same issue with GUI, it has to do with the API server and the network mechanics.

    However, even if the logs are successfully downloaded, a malfunction at gh side is technically possible. When you run gh run view --log, gh downloads the ZIP archive logs from the API and stores it in its cache directory (e.g. ~/.cache/gh on Unix/Linux). The file name is formatted as run-log-99999999999-9999999999.zip. That is why the next time you run the same gh run view --log command, it'll take much less time displaying the logs.

    When the download is done, gh finds the right job run within the ZIP archive, prefixes the lines with job/step name fields, and finally pipes them to stdout which is piped into the stdin of a pager (less by default on Unix/Linux). And this is where we may see problems, because we're pushing all log content to the stdin of another process (the pager), and seeing the problem really depends on the host resources (e.g. memory), and the way the pager handles large inputs.

    Anyway, I tested gh with a syntactic 500M log file (363M ZIP file), and despite a few seconds lag when you jump to the end of the log stream, gh and less work nicely together. Again, it depends on various parameters.

    Now, @ptorgalmath-gpsw, can you please tell me what's your experience with gh when the initial download is successful? You can check gh cache directory to see if the ZIP file is there.

  2. added
    more-info-neededMore info needed from user/contributor
    platformProblems with the GitHub platform rather than the CLI client
    gh-runrelating to the gh run command
    and removed
    bugSomething isn't working
    on Jun 12, 2025
  3. dlvhdr commented on Jun 15, 2025

    @dlvhdr

    I'm facing the same issue and did some digging.

    • The zip file is downloaded correctly, but seems like gh is unable to unzip it.
    • Running unzip myself, I get some Illegal byte sequence messages.
    • Following this stackoverflow post it seems like the unzip util on mac is quite old.
    • Downloading unar extracts it just fine.
  4. babakks commented on Jun 16, 2025

    @babakks
    Member

    @dlvhdr, if gh couldn't read the ZIP file you'll see an error messaging. I mean it won't just show an empty log trail.

    Can you please share with me what you get when you run gh run view --log command?

  5. dlvhdr commented on Jun 16, 2025

    @dlvhdr

    I'm guessing there's some kind of error that is swallowed, I'm getting no output.

    Screen.Recording.2025-06-16.at.15.03.47.mov

    Also, the exit status is 0.

    Viewing the check on the web works fine:

    Image

  6. dlvhdr commented on Jun 16, 2025

    @dlvhdr

    @babakks I think I found the issue, but not sure if the fix will break other stuff.
    In https://github.com/cli/cli/blob/trunk/pkg/cmd/run/view/view.go?plain=1#L552, if I swap it like so, the issue is fixed:

    - sanitizedJobName := strings.ReplaceAll(name, "/", "")
    + sanitizedJobName := strings.ReplaceAll(name, "/", "_")

    The job name in my case is Run frontend tests / Cypress 4 🌲.
    And the file name in the zip is 12_Run frontend tests _ Cypress 4 🌲.txt.
    gh currently looks for a file named 12_Run frontend tests Cypress 4 🌲.txt which it obviously doesn't find.
    Maybe the logic in the server that produces these files changed?

  7. babakks commented on Jun 16, 2025

    @babakks
    Member

    Thanks for details, @dlvhdr! 🙏

    Yeah, the problem can be the way the Actions backend sanitises file names in the ZIP archive. We have already captured this in #10868, and @williammartin and I are working on a fix that will help with your case as well.

    Unfortunately, your suggestion is a breaking change. Currently, the ZIP archives are served by two versions of a backend service and they're not exactly producing the same ZIP structure. As said, we're working on a fix that will probably help with this case.

  8. williammartin commented on Jun 16, 2025

    @williammartin
    Member

    Well, I think we should probably accept either character. Even with the fix we have, we should always endeavour to find the log files in the zip file for performance and availability reasons.

  9. babakks commented on Jun 16, 2025

    @babakks
    Member

    Yeah, definitely. That's what the other issue is about.

  10. 1 remaining item

  11. babakks commented on Jul 4, 2025

    @babakks
    Member

    @ptorgalmath-gpsw, this error means the other party (server) has cancelled the stream. That's why you don't see a ZIP file created under ~/.cache/gh.

    The first step is to make sure this termination has anything to do with the Go HTTP client that gh is using.

    To verify this, you can try downloading the archive via the following curl command:

    curl -L \
         -H "Accept: application/vnd.github+json" \
         -H "Authorization: Bearer $(gh auth token)" \
         -H "X-GitHub-Api-Version: 2022-11-28" \
         -o run-log.zip
         https://api.github.com/repos/OWNER/REPO/actions/runs/RUN_ID/logs

    Note that you should replace OWNER, REPO and RUN_ID with the right values. Also $(gh auth token) already inserts your auth token.

    If curl can download the ZIP archive, then we need to dig deeper and see what's going on with Go HTTP client. If curl couldn't, then there's something with the platform infra that is killing the stream.

    Could you please try the command above and share your observations, @ptorgalmath-gpsw?

  12. ptorgalmath-gpsw commented on Jul 8, 2025

    @ptorgalmath-gpsw
    Author

    It failed to download the ZIP archive, here's what I see
    % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 18.7M 0 18.7M 0 0 627k 0 --:--:-- 0:00:30 --:--:-- 1318k curl: (92) HTTP/2 stream 1 was not closed cleanly: CANCEL (err 8)
    cc: @babakks

  13. babakks commented on Jul 8, 2025

    @babakks
    Member

    This seems like a network/infra issue. Could you please retry curl with --http1.1 to enforce HTTP/1.1?

  14. ptorgalmath-gpsw commented on Jul 8, 2025

    @ptorgalmath-gpsw
    Author

    I still get an error curl: (18) transfer closed with outstanding read data remaining. So you think this could be something on my MacBook causing this?
    cc: @babakks

  15. babakks commented on Jul 8, 2025

    @babakks
    Member

    Thanks for checking out, @ptorgalmath-gpsw! 🙏 I can't rule out that possibility, but it seems remote.

    As I'm checking online resources, this can happen due to an incorrect Content-Length header value sent by the server. Can you please try curl again with --ignore-content-length option?

  16. ptorgalmath-gpsw commented on Jul 8, 2025

    @ptorgalmath-gpsw
    Author

    Unfortunately that flag didn't help either, I'm also working with our IT to figure out if it's something we are enforcing. Here's the error with flag --ignore-content-length
    % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 27.1M 0 27.1M 0 0 908k 0 --:--:-- 0:00:30 --:--:-- 1140k curl: (18) transfer closed with outstanding read data remaining

    Also it always times out at 30 secs.

    cc: @babakks

  17. ptorgalmath-gpsw commented on Jul 9, 2025

    @ptorgalmath-gpsw
    Author

    Worked with our IT, it doesn't look like the issue is from our IT blocking the download, just wanted to update.

  18. ptorgalmath-gpsw commented on Jul 9, 2025

    @ptorgalmath-gpsw
    Author

    I tried on a non company device and the result was the same using browser download via GitHub.com. So we can rule out our IT blocking us from downloading the file.

  19. babakks commented on Jul 9, 2025

    @babakks
    Member

    Thanks again for helping us isolate the problem, @ptorgalmath-gpsw! 🎉

    As of our internal comms, there actually is an intentional timeout here, which confirms your observation. But it's not clear if that's going to be changed/improved. So, I'm going to label this issue as platform related case, as there's nothing gh could do at the moment.

    As an alternative solution to unblock you, since you're trying to get the logs for a specific job, you can use gh api to directly fetch the job logs from the API. However, the result will not be as nice as gh run view --log output. Here's the command:

    gh api /repos/OWNER/REPO/actions/jobs/JOB-ID/logs

    Where OWNER, REPO, and JOB-ID have to be replaced with the right values.

  20. ptorgalmath-gpsw commented on Jul 9, 2025

    @ptorgalmath-gpsw
    Author

    Thanks for the update. The api works fine, for now I can get logs via gh api but can we try to find a resolution to downloading logs via web browser or gh run? thanks

    @babakks

  21. williammartin commented on Jul 10, 2025

    @williammartin
    Member

    We've brought it up with the team that owns the service that provides the logs but in practice, they need to pick some limit and whatever limit they pick will impact some amount of people depending on internet speed and total log size. Do you have any idea how big your total log zip might be? You're getting cut off at around 27MB since you're downloading a little under 1MB per second and hit the 30 second limit.

    I'm not sure where you are located? Is 1MB/s surprisingly low? Maybe you could do a speedtest elsewhere and see what you get.

  22. williammartin commented on Jul 10, 2025

    @williammartin
    Member

    Some further investigation makes me think there is something suspicious happening on the server, as I get timed out at a similar amount downloaded, despite speedtest.net showing me working at 10x this speed.

    ➜  test-repo git:(main) curl -L \
         -H "Accept: application/vnd.github+json" \
         -H "Authorization: Bearer $(gh auth token)" \
         -H "X-GitHub-Api-Version: 2022-11-28" \
         -o run-log.zip \
         https://api.github.com/repos/williammartin/test-repo/actions/runs/16193257615/logs
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    100 35.6M    0 35.6M    0     0  1194k      0 --:--:--  0:00:30 --:--:--  751k
    curl: (92) HTTP/2 stream 1 was not closed cleanly: CANCEL (err 8)
    

    Will bring this back to the team that owns the service.

  23. ptorgalmath-gpsw commented on Jul 10, 2025

    @ptorgalmath-gpsw
    Author

    yes @williammartin you are right, my speed test also returned 10x but the timeout is set to a certain amount, doesn't matter how fast the download is it times out because the logs are huge. So far the biggest ZIP that I was partially able to download was 80MB. I'm also working with the team to get log size reduced because it is mostly warnings. But to me 30secs seems too quick to stop the download. Is there any other forum I need to open a ticket or ask about this so it has visibility? Thanks.

  24. williammartin commented on Jul 10, 2025

    @williammartin
    Member

    You could raise a support ticket through your organisation's plan, if you have that option, that might help it get prioritised.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    gh-runrelating to the gh run commandplatformProblems with the GitHub platform rather than the CLI client

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions