Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/api-client/src/modules/labrinth/versions/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AbstractModule } from '../../../core/abstract-module'
import type { UploadHandle } from '../../../types/upload'
import type { Labrinth } from '../types'

const VERSION_UPLOAD_TIMEOUT_MS = 30 * 60 * 1000

export class LabrinthVersionsV3Module extends AbstractModule {
public getModuleID(): string {
return 'labrinth_versions_v3'
Expand Down Expand Up @@ -199,7 +201,7 @@ export class LabrinthVersionsV3Module extends AbstractModule {
api: 'labrinth',
version: 3,
formData,
timeout: 60 * 5 * 1000,
timeout: VERSION_UPLOAD_TIMEOUT_MS,
})
}

Expand Down Expand Up @@ -284,7 +286,7 @@ export class LabrinthVersionsV3Module extends AbstractModule {
api: 'labrinth',
version: 2,
formData,
timeout: 60 * 5 * 1000,
timeout: VERSION_UPLOAD_TIMEOUT_MS,
})
}
}
5 changes: 5 additions & 0 deletions packages/api-client/src/platform/xhr-upload-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export abstract class XHRUploadClient extends AbstractModrinthClient {

xhr.addEventListener('error', () => reject(new ModrinthApiError('Upload failed')))
xhr.addEventListener('abort', () => reject(new ModrinthApiError('Upload cancelled')))
xhr.addEventListener('timeout', () => reject(new ModrinthApiError('Upload timed out')))

if (context.options.timeout !== undefined) {
xhr.timeout = context.options.timeout
}

// build URL with params (unlike $fetch, XHR doesn't handle params automatically)
let url = context.url
Expand Down
Loading