mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-10 11:40:28 +08:00
fix: prevent profile switch queue from breaking after failed switch
This commit is contained in:
parent
56e328191f
commit
3c148f2c01
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -263,7 +263,7 @@ jobs:
|
||||
arch:
|
||||
- x64
|
||||
- arm64
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
@ -65,7 +65,11 @@ export async function getProfileItem(id: string | undefined): Promise<IProfileIt
|
||||
|
||||
export async function changeCurrentProfile(id: string): Promise<void> {
|
||||
// 使用队列确保 profile 切换串行执行,避免竞态条件
|
||||
changeProfileQueue = changeProfileQueue.then(async () => {
|
||||
let taskError: unknown = null
|
||||
changeProfileQueue = changeProfileQueue
|
||||
.catch(() => {
|
||||
})
|
||||
.then(async () => {
|
||||
const { current } = await getProfileConfig()
|
||||
if (current === id) return
|
||||
|
||||
@ -81,10 +85,13 @@ export async function changeCurrentProfile(id: string): Promise<void> {
|
||||
config.current = current
|
||||
return config
|
||||
})
|
||||
throw e
|
||||
taskError = e
|
||||
}
|
||||
})
|
||||
await changeProfileQueue
|
||||
if (taskError) {
|
||||
throw taskError
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateProfileItem(item: IProfileItem): Promise<void> {
|
||||
@ -249,6 +256,14 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
||||
useProxy: true,
|
||||
timeout: subscriptionTimeout
|
||||
})
|
||||
} else if (newItem.substore) {
|
||||
// SubStore requests (especially collections) need more time as they fetch and merge multiple subscriptions
|
||||
// Use the full subscriptionTimeout since SubStore is a local server and doesn't need smart fallback
|
||||
result = await fetchAndValidateSubscription({
|
||||
...baseOptions,
|
||||
useProxy: false,
|
||||
timeout: subscriptionTimeout
|
||||
})
|
||||
} else {
|
||||
const smartTimeout = 5000
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user