fix: avoid lost writes by running bulk proxy pool updates sequentially against JSON db
Made-with: Cursor
This commit is contained in:
parent
880f4eca91
commit
f94ac213b5
1 changed files with 9 additions and 5 deletions
|
|
@ -334,16 +334,20 @@ export default function ProviderDetailPage() {
|
||||||
const proxyPoolId = bulkProxyPoolId === "__none__" ? null : bulkProxyPoolId;
|
const proxyPoolId = bulkProxyPoolId === "__none__" ? null : bulkProxyPoolId;
|
||||||
setBulkUpdatingProxy(true);
|
setBulkUpdatingProxy(true);
|
||||||
try {
|
try {
|
||||||
const results = await Promise.all(
|
const results = [];
|
||||||
selectedConnectionIds.map(async (connectionId) => {
|
for (const connectionId of selectedConnectionIds) {
|
||||||
|
try {
|
||||||
const res = await fetch(`/api/providers/${connectionId}`, {
|
const res = await fetch(`/api/providers/${connectionId}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ proxyPoolId }),
|
body: JSON.stringify({ proxyPoolId }),
|
||||||
});
|
});
|
||||||
return res.ok;
|
results.push(res.ok);
|
||||||
})
|
} catch (e) {
|
||||||
);
|
console.log("Error applying bulk proxy pool for", connectionId, e);
|
||||||
|
results.push(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const failedCount = results.filter((ok) => !ok).length;
|
const failedCount = results.filter((ok) => !ok).length;
|
||||||
if (failedCount > 0) {
|
if (failedCount > 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue