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:
anonpenguin23 2026-02-21 19:26:14 +02:00
parent 15b3bb382e
commit 743b78faa8
5 changed files with 18 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"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",
"type": "module",
"main": "./dist/index.js",

View File

@ -138,7 +138,11 @@ export class WSClient {
if (this.authToken) {
const separator = url.includes("?") ? "&" : "?";
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;

View File

@ -190,9 +190,10 @@ export class StorageClient {
throw error;
}
// Wait before retrying (exponential backoff: 400ms, 800ms, 1200ms, etc.)
// This gives up to ~12 seconds total wait time, covering typical pin completion
const backoffMs = attempt * 2500;
// Wait before retrying with bounded exponential backoff
// Max 3 seconds per retry to fit within 30s test timeout
// 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));
}
}
@ -248,9 +249,10 @@ export class StorageClient {
throw error;
}
// Wait before retrying (exponential backoff: 400ms, 800ms, 1200ms, etc.)
// This gives up to ~12 seconds total wait time, covering typical pin completion
const backoffMs = attempt * 2500;
// Wait before retrying with bounded exponential backoff
// Max 3 seconds per retry to fit within 30s test timeout
// 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));
}
}

View File

@ -20,7 +20,7 @@ describe("Cache", () => {
} catch (err) {
// Ignore errors during cleanup
}
});
}, 30000); // 30 second timeout for slow SCAN operations
it("should check cache health", async () => {
const client = await createTestClient();

View File

@ -116,6 +116,9 @@ describe("Storage", () => {
const uploadResult = await client.storage.upload(testFile);
const cid = uploadResult.cid;
// Wait for IPFS replication across nodes (30 seconds)
await new Promise((resolve) => setTimeout(resolve, 2000));
// Get the content back
const stream = await client.storage.get(cid);