@@ -160,20 +160,24 @@ export const fetchBlobs = async (paths, query) => {
160160 return { } ;
161161 }
162162
163+ const { isSelfHosted = false } = repository ;
164+ const batchSize = isSelfHosted ? 20 : 100 ;
163165 const fetchingPaths = [ ...paths ] ;
164166 /** @type {BlobItem[] } */
165167 const blobs = [ ] ;
166168
167169 // Fetch all the text contents with the GraphQL API. Pagination would fail if `paths` becomes too
168170 // long, so we just use a fixed number of paths to iterate. The complexity score of this query is
169- // 15 + (2 * node size) so 50 paths = 115 complexity, giving the following conditions:
171+ // 15 + (2 * node size) so 100 paths = 215 complexity, giving the following conditions:
170172 // 1. The max number of records is 100
171173 // 2. The max query complexity is 250 or 300
172174 // 3. The total blob size must be under 20 MB (since GitLab 18.4.5)
173175 // @see https://github.com/sveltia/sveltia-cms/issues/525
174176 // @see https://gitlab.com/gitlab-org/gitlab/-/issues/576497
177+ // The batch size is reduced to 20 for self-hosted instances because they typically run on less
178+ // powerful hardware, which may lead to timeout issues.
175179 for ( ; ; ) {
176- const currentPaths = fetchingPaths . splice ( 0 , 50 ) ;
180+ const currentPaths = fetchingPaths . splice ( 0 , batchSize ) ;
177181
178182 const result = /** @type {FetchBlobsResponse } */ (
179183 await fetchGraphQL ( query , { paths : currentPaths } )
@@ -258,12 +262,12 @@ export const fetchCommits = async (paths) => {
258262 * Parse the file contents from the API response.
259263 * @param {object } args Arguments.
260264 * @param {BaseFileListItem[] } args.fetchingFiles Base file list.
261- * @param {Record<string, BlobItem> } args.sizes File sizes.
262265 * @param {Record<string, BlobItem> } args.blobs Raw text blobs.
266+ * @param {Record<string, BlobItem> } [args.sizes] File sizes.
263267 * @param {Record<string, GitLabCommit> } [args.commits] Commit information for each file.
264268 * @returns {Promise<RepositoryContentsMap> } Parsed file contents map.
265269 */
266- export const parseFileContents = async ( { fetchingFiles, sizes , blobs , commits = { } } ) => {
270+ export const parseFileContents = async ( { fetchingFiles, blobs , sizes = { } , commits = { } } ) => {
267271 const entries = fetchingFiles . map ( ( { path, sha } ) => {
268272 const commit = commits [ path ] ;
269273
@@ -307,19 +311,16 @@ export const fetchFileContents = async (fetchingFiles) => {
307311 // Show a fake progressbar because the request waiting time is long
308312 const dataLoadedProgressInterval = window . setInterval ( ( ) => {
309313 dataLoadedProgress . update ( ( progress = 0 ) => progress + 1 ) ;
310- } , fetchingFiles . length / 2 ) ;
314+ } , fetchingFiles . length / 10 ) ;
311315
312316 // Fetch blobs for entry/config files only
313317 const textPaths = fetchingFiles . filter ( ( { type } ) => type !== 'asset' ) . map ( ( { path } ) => path ) ;
314318 const blobs = await fetchBlobs ( textPaths , FETCH_BLOBS_QUERY ) ;
315- // Fetch sizes for asset files only
316- const assetPaths = fetchingFiles . filter ( ( { type } ) => type === 'asset' ) . map ( ( { path } ) => path ) ;
317- const sizes = await fetchBlobs ( assetPaths , FETCH_BLOBS_QUERY . replace ( 'rawTextBlob' , 'size' ) ) ;
318319
319320 window . clearInterval ( dataLoadedProgressInterval ) ;
320321 dataLoadedProgress . set ( undefined ) ;
321322
322- return parseFileContents ( { fetchingFiles, sizes , blobs } ) ;
323+ return parseFileContents ( { fetchingFiles, blobs } ) ;
323324} ;
324325
325326/**
0 commit comments