@@ -110,7 +110,7 @@ def possible_image_file_names_for_collection(collection)
110110GRAPHQL_BATCH_SIZE = 100
111111
112112def prefetch_all_collection_items!
113- return if @_prefetched
113+ return if NewOctokit . global_prefetch_done?
114114
115115 all_repos = [ ]
116116 all_users = [ ]
@@ -128,21 +128,26 @@ def prefetch_all_collection_items!
128128 all_repos . uniq!
129129 all_users . uniq!
130130
131- # Batch repos in chunks to stay within GraphQL query limits
132- all_repos . each_slice ( GRAPHQL_BATCH_SIZE ) do |batch |
133- cache_repos_exist_check! ( batch )
134- end
131+ begin
132+ # Batch repos in chunks to stay within GraphQL query limits
133+ all_repos . each_slice ( GRAPHQL_BATCH_SIZE ) do |batch |
134+ cache_repos_exist_check! ( batch )
135+ end
135136
136- # Batch users in chunks
137- all_users . each_slice ( GRAPHQL_BATCH_SIZE ) do |batch |
138- cache_users_exist_check! ( batch )
139- end
137+ # Batch users in chunks
138+ all_users . each_slice ( GRAPHQL_BATCH_SIZE ) do |batch |
139+ cache_users_exist_check! ( batch )
140+ end
140141
141- # Check orgs for users not found
142- not_found_users = users_not_found_from ( all_users )
143- not_found_users . each_slice ( GRAPHQL_BATCH_SIZE ) do |batch |
144- cache_orgs_exist_check! ( batch )
145- end
142+ # Check orgs for users not found
143+ not_found_users = users_not_found_from ( all_users )
144+ not_found_users . each_slice ( GRAPHQL_BATCH_SIZE ) do |batch |
145+ cache_orgs_exist_check! ( batch )
146+ end
146147
147- @_prefetched = true
148+ # Only mark as done after ALL batch calls completed successfully
149+ NewOctokit . global_prefetch_done!
150+ rescue StandardError => error
151+ warn "Global prefetch failed, falling back to per-test caching: #{ error . message } "
152+ end
148153end
0 commit comments