lightnode-sdk 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/inference.js +13 -4
- package/package.json +1 -1
package/dist/inference.js
CHANGED
|
@@ -283,13 +283,22 @@ export async function runJobOnSession(session, prompt, opts = {}, attempt = 1) {
|
|
|
283
283
|
// Shim so the job body below can keep referencing prepared.* unchanged.
|
|
284
284
|
const prepared = { sessionKey, createSessionArgs: { worker } };
|
|
285
285
|
// 3. relay token + WebSocket
|
|
286
|
+
// Poll the gateway for the relay token with a fast backoff (it's usually ready
|
|
287
|
+
// within ~1s of createSession). Catch it sooner than a fixed 1s interval, and
|
|
288
|
+
// cap the total at a 20s deadline instead of 30 fixed iterations.
|
|
286
289
|
let relayToken;
|
|
287
|
-
|
|
290
|
+
const tokenDeadline = Date.now() + 20000;
|
|
291
|
+
let tokenDelay = 250;
|
|
292
|
+
while (!relayToken) {
|
|
288
293
|
const r = await gateway.getSessionToken(Number(sessionId));
|
|
289
|
-
if ("token" in r && r.token)
|
|
294
|
+
if ("token" in r && r.token) {
|
|
290
295
|
relayToken = r.token;
|
|
291
|
-
|
|
292
|
-
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
if (Date.now() >= tokenDeadline)
|
|
299
|
+
break;
|
|
300
|
+
await new Promise((res) => setTimeout(res, tokenDelay));
|
|
301
|
+
tokenDelay = Math.min(tokenDelay * 2, 2000);
|
|
293
302
|
}
|
|
294
303
|
if (!relayToken)
|
|
295
304
|
throw new RelayTokenTimeoutError();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lightnode-sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Read-only TypeScript client for LightChain AI: workers, jobs, models, on-chain registration, and per-model network analytics. Independent, community-built (not an official LightChain package).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|