*Add missing resolve call
This commit is contained in:
parent
d778255b2a
commit
6aca65b3e1
34
src/index.ts
34
src/index.ts
|
@ -1,4 +1,4 @@
|
||||||
import { addHandler, handleMessage } from "libkmodule";
|
import { addHandler, handleMessage , log} from "libkmodule";
|
||||||
import type { ActiveQuery } from "libkmodule";
|
import type { ActiveQuery } from "libkmodule";
|
||||||
import PQueue from "p-queue";
|
import PQueue from "p-queue";
|
||||||
import { ipfsPath, ipnsPath } from "is-ipfs";
|
import { ipfsPath, ipnsPath } from "is-ipfs";
|
||||||
|
@ -68,7 +68,7 @@ async function handleStatIpns(aq: ActiveQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleFetchIpns(aq: ActiveQuery) {
|
async function handleFetchIpns(aq: ActiveQuery) {
|
||||||
return handleStat(aq, "fetch_ipns", "ipns");
|
return handleFetch(aq, "fetch_ipns", "ipns");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function validateInputs(aq: ActiveQuery, type: "ipns" | "ipfs") {
|
async function validateInputs(aq: ActiveQuery, type: "ipns" | "ipfs") {
|
||||||
|
@ -206,6 +206,7 @@ async function rpcCall(
|
||||||
reject(response?.error || response?.data?.error);
|
reject(response?.error || response?.data?.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stream && 1 === dataCount) {
|
if (!stream && 1 === dataCount) {
|
||||||
socket.end();
|
socket.end();
|
||||||
resolve(response?.data);
|
resolve(response?.data);
|
||||||
|
@ -216,6 +217,7 @@ async function rpcCall(
|
||||||
stream(response?.data.data);
|
stream(response?.data.data);
|
||||||
if (response?.data.done) {
|
if (response?.data.done) {
|
||||||
socket.end();
|
socket.end();
|
||||||
|
resolve(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -228,37 +230,13 @@ async function rpcCall(
|
||||||
force: true,
|
force: true,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
timer = setTimeout(() => {
|
/* timer = setTimeout(() => {
|
||||||
socket.end();
|
socket.end();
|
||||||
reject("timeout");
|
reject("timeout");
|
||||||
}, 10 * 1000) as NodeJS.Timeout;
|
}, 10 * 1000) as NodeJS.Timeout;*/
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processStream(aq: ActiveQuery, response: Response) {
|
|
||||||
const reader = response.body.getReader();
|
|
||||||
|
|
||||||
let aqResp = {
|
|
||||||
headers: Array.from(response.headers),
|
|
||||||
status: response.status,
|
|
||||||
};
|
|
||||||
while (true) {
|
|
||||||
let chunk;
|
|
||||||
|
|
||||||
try {
|
|
||||||
chunk = await reader.read();
|
|
||||||
aq.sendUpdate(chunk.value);
|
|
||||||
if (chunk.done) {
|
|
||||||
aq.respond(aqResp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
aq.respond(aqResp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function refreshGatewayList() {
|
async function refreshGatewayList() {
|
||||||
let processResolve: any;
|
let processResolve: any;
|
||||||
blockingGatewayUpdate = new Promise((resolve) => {
|
blockingGatewayUpdate = new Promise((resolve) => {
|
||||||
|
|
Loading…
Reference in New Issue