mirror of
https://github.com/DeBrosOfficial/network-ts-sdk.git
synced 2026-03-16 18:23:01 +00:00
Bump version to 0.6.1; improve WSClient auth token handling and add bounded exponential backoff in StorageClient retries; update test timeouts for cache and storage tests
This commit is contained in:
parent
15b3bb382e
commit
743b78faa8
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@debros/network-ts-sdk",
|
"name": "@debros/network-ts-sdk",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"description": "TypeScript SDK for DeBros Network Gateway - Database, PubSub, Cache, Storage, and more",
|
"description": "TypeScript SDK for DeBros Network Gateway - Database, PubSub, Cache, Storage, and more",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@ -138,7 +138,11 @@ export class WSClient {
|
|||||||
if (this.authToken) {
|
if (this.authToken) {
|
||||||
const separator = url.includes("?") ? "&" : "?";
|
const separator = url.includes("?") ? "&" : "?";
|
||||||
const paramName = this.authToken.startsWith("ak_") ? "api_key" : "token";
|
const paramName = this.authToken.startsWith("ak_") ? "api_key" : "token";
|
||||||
url += `${separator}${paramName}=${encodeURIComponent(this.authToken)}`;
|
// API keys contain a colon (ak_xxx:namespace) that must not be percent-encoded
|
||||||
|
const encodedToken = this.authToken.startsWith("ak_")
|
||||||
|
? this.authToken
|
||||||
|
: encodeURIComponent(this.authToken);
|
||||||
|
url += `${separator}${paramName}=${encodedToken}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
|
|||||||
@ -190,9 +190,10 @@ export class StorageClient {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait before retrying (exponential backoff: 400ms, 800ms, 1200ms, etc.)
|
// Wait before retrying with bounded exponential backoff
|
||||||
// This gives up to ~12 seconds total wait time, covering typical pin completion
|
// Max 3 seconds per retry to fit within 30s test timeout
|
||||||
const backoffMs = attempt * 2500;
|
// Total: 1s + 2s + 3s + 3s + 3s + 3s + 3s + 3s = 21 seconds
|
||||||
|
const backoffMs = Math.min(attempt * 1000, 3000);
|
||||||
await new Promise((resolve) => setTimeout(resolve, backoffMs));
|
await new Promise((resolve) => setTimeout(resolve, backoffMs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,9 +249,10 @@ export class StorageClient {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait before retrying (exponential backoff: 400ms, 800ms, 1200ms, etc.)
|
// Wait before retrying with bounded exponential backoff
|
||||||
// This gives up to ~12 seconds total wait time, covering typical pin completion
|
// Max 3 seconds per retry to fit within 30s test timeout
|
||||||
const backoffMs = attempt * 2500;
|
// Total: 1s + 2s + 3s + 3s + 3s + 3s + 3s + 3s = 21 seconds
|
||||||
|
const backoffMs = Math.min(attempt * 1000, 3000);
|
||||||
await new Promise((resolve) => setTimeout(resolve, backoffMs));
|
await new Promise((resolve) => setTimeout(resolve, backoffMs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ describe("Cache", () => {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Ignore errors during cleanup
|
// Ignore errors during cleanup
|
||||||
}
|
}
|
||||||
});
|
}, 30000); // 30 second timeout for slow SCAN operations
|
||||||
|
|
||||||
it("should check cache health", async () => {
|
it("should check cache health", async () => {
|
||||||
const client = await createTestClient();
|
const client = await createTestClient();
|
||||||
|
|||||||
@ -116,6 +116,9 @@ describe("Storage", () => {
|
|||||||
const uploadResult = await client.storage.upload(testFile);
|
const uploadResult = await client.storage.upload(testFile);
|
||||||
const cid = uploadResult.cid;
|
const cid = uploadResult.cid;
|
||||||
|
|
||||||
|
// Wait for IPFS replication across nodes (30 seconds)
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
|
|
||||||
// Get the content back
|
// Get the content back
|
||||||
const stream = await client.storage.get(cid);
|
const stream = await client.storage.get(cid);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user