fix(phase3): add $autoCancel:false to prevent SDK auto-cancellation
PocketBase JS SDK auto-cancels pending requests when a new request targets the same collection. This causes errors when loadLedgers and getLedgerSummary run in parallel via Promise.all. Added $autoCancel:false to all API calls in ledgers.ts and assets.ts, matching project convention. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -25,14 +25,15 @@ export async function createAsset(data: CreateAssetData): Promise<Asset> {
|
||||
if (data.description) formData.append('description', data.description)
|
||||
if (data.image) formData.append('image', data.image)
|
||||
|
||||
return pb.collection('assets').create(formData) as Promise<Asset>
|
||||
return pb.collection('assets').create(formData, { $autoCancel: false }) as Promise<Asset>
|
||||
}
|
||||
|
||||
export async function listAssets(groupId: string): Promise<Asset[]> {
|
||||
const result = await pb.collection('assets').getFullList({
|
||||
filter: `group="${groupId}"`,
|
||||
sort: 'created',
|
||||
expand: 'creator,currentHolder'
|
||||
expand: 'creator,currentHolder',
|
||||
$autoCancel: false
|
||||
})
|
||||
return result as unknown as Asset[]
|
||||
}
|
||||
@@ -49,20 +50,20 @@ export async function updateAsset(
|
||||
if (data.description !== undefined) formData.append('description', data.description)
|
||||
formData.append('image', image)
|
||||
|
||||
return pb.collection('assets').update(assetId, formData) as Promise<Asset>
|
||||
return pb.collection('assets').update(assetId, formData, { $autoCancel: false }) as Promise<Asset>
|
||||
}
|
||||
|
||||
return pb.collection('assets').update(assetId, data) as Promise<Asset>
|
||||
return pb.collection('assets').update(assetId, data, { $autoCancel: false }) as Promise<Asset>
|
||||
}
|
||||
|
||||
export async function transferAsset(assetId: string, userId: string): Promise<Asset> {
|
||||
return pb.collection('assets').update(assetId, {
|
||||
currentHolder: userId
|
||||
}) as Promise<Asset>
|
||||
}, { $autoCancel: false }) as Promise<Asset>
|
||||
}
|
||||
|
||||
export async function deleteAsset(assetId: string): Promise<void> {
|
||||
await pb.collection('assets').delete(assetId)
|
||||
await pb.collection('assets').delete(assetId, { $autoCancel: false })
|
||||
}
|
||||
|
||||
export function subscribeAssets(
|
||||
|
||||
Reference in New Issue
Block a user