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

[bug] timeout fetching file in PR review window for newly added files #817

Closed
raulchen opened this issue Jan 24, 2025 · 2 comments · Fixed by #822
Closed

[bug] timeout fetching file in PR review window for newly added files #817

raulchen opened this issue Jan 24, 2025 · 2 comments · Fixed by #822
Labels
bug Something wrong in the code

Comments

@raulchen
Copy link
Contributor

In the PR review UI, when I switch to a newly added file , octo will complains Error fetching <file_name>".

The following patch fixes the issue for me. I'd be happy to submit a PR if the fix looks good to you.

diff --git a/lua/octo/reviews/file-entry.lua b/lua/octo/reviews/file-entry.lua
index 1058602..70f8920 100644
--- a/lua/octo/reviews/file-entry.lua
+++ b/lua/octo/reviews/file-entry.lua
@@ -77,7 +77,9 @@ function FileEntry:new(opt)
     left_binary = opt.left_binary,
     right_binary = opt.right_binary,
     left_lines = {},
+    left_fetched = false,
     right_lines = {},
+    right_fetched = false,
     diffhunks = diffhunks,
     associated_bufs = {},
     viewed_state = pr.files[opt.path],
@@ -205,10 +207,12 @@ function FileEntry:fetch()
   if self.pull_request.local_right then
     utils.get_file_at_commit(right_path, right_sha, function(lines)
       self.right_lines = lines
+      self.right_fetched = true
     end)
   else
     utils.get_file_contents(self.pull_request.repo, right_abbrev, right_path, function(lines)
       self.right_lines = lines
+      self.right_fetched = true
     end)
   end
 
@@ -216,10 +220,12 @@ function FileEntry:fetch()
   if self.pull_request.local_left then
     utils.get_file_at_commit(left_path, left_sha, function(lines)
       self.left_lines = lines
+      self.left_fetched = true
     end)
   else
     utils.get_file_contents(self.pull_request.repo, left_abbrev, left_path, function(lines)
       self.left_lines = lines
+      self.left_fetched = true
     end)
   end
 
@@ -232,7 +238,7 @@ end
 ---Determines whether the file content has been loaded and the file is ready to render
 ---@return boolean
 function FileEntry:is_ready_to_render()
-  return #self.left_lines > 0 and #self.right_lines > 0
+  return self.left_fetched and self.right_fetched
 end
 
 ---Load the buffers.
@wd60622 wd60622 added the bug Something wrong in the code label Jan 25, 2025
@wd60622
Copy link
Collaborator

wd60622 commented Jan 25, 2025

A PR would be appreciated! Good catch

@raulchen
Copy link
Contributor Author

Here we go #822

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something wrong in the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants