diff --git a/package.json b/package.json index 62ce30c..b41b0c7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core/ws.ts b/src/core/ws.ts index 8e1f997..4f69baf 100644 --- a/src/core/ws.ts +++ b/src/core/ws.ts @@ -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; diff --git a/src/storage/client.ts b/src/storage/client.ts index 3f7986e..a923cfb 100644 --- a/src/storage/client.ts +++ b/src/storage/client.ts @@ -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)); } } diff --git a/tests/e2e/cache.test.ts b/tests/e2e/cache.test.ts index ae750eb..f2dc61c 100644 --- a/tests/e2e/cache.test.ts +++ b/tests/e2e/cache.test.ts @@ -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(); diff --git a/tests/e2e/storage.test.ts b/tests/e2e/storage.test.ts index 0993dd4..2adea9c 100644 --- a/tests/e2e/storage.test.ts +++ b/tests/e2e/storage.test.ts @@ -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);