mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-30 08:22:34 +00:00
Merge pull request #4618 from superman2003/fix/system-update-detach-request-ctx
fix(update): detach in-place update from the HTTP request lifetime
This commit is contained in:
@@ -61,12 +61,22 @@ export async function getRollbackVersions(): Promise<{ versions: RollbackVersion
|
||||
return data
|
||||
}
|
||||
|
||||
/**
|
||||
* In-place update/rollback downloads a full release binary from GitHub, which
|
||||
* can take several minutes on slow links. The global 30s axios timeout would
|
||||
* abort the request mid-download (#4504), so these calls wait as long as the
|
||||
* backend allows (15 minutes server-side).
|
||||
*/
|
||||
const UPDATE_REQUEST_TIMEOUT_MS = 15 * 60 * 1000
|
||||
|
||||
/**
|
||||
* Perform system update
|
||||
* Downloads and applies the latest version
|
||||
*/
|
||||
export async function performUpdate(): Promise<UpdateResult> {
|
||||
const { data } = await apiClient.post<UpdateResult>('/admin/system/update')
|
||||
const { data } = await apiClient.post<UpdateResult>('/admin/system/update', undefined, {
|
||||
timeout: UPDATE_REQUEST_TIMEOUT_MS
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -77,7 +87,8 @@ export async function performUpdate(): Promise<UpdateResult> {
|
||||
export async function rollback(version?: string): Promise<UpdateResult> {
|
||||
const { data } = await apiClient.post<UpdateResult>(
|
||||
'/admin/system/rollback',
|
||||
version ? { version } : undefined
|
||||
version ? { version } : undefined,
|
||||
{ timeout: UPDATE_REQUEST_TIMEOUT_MS }
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user