Skip to content

Commit

Permalink
added error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj committed Apr 19, 2024
1 parent 6f08ba9 commit 7b533ff
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/datasource/graphene/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function decodeChunkedGraphChunk(leaves: string[]) {
class BulkRequestProxy {
pendingRequests = new Map<
string,
[Signal<(request: any) => void>, Uint64Set]
[Signal<(response: any) => void>, Uint64Set]
>();

constructor(
Expand All @@ -291,26 +291,35 @@ class BulkRequestProxy {
}
const [_, segments] = pendingRequest;
_;
const response = await cancellableFetchSpecialOk(
credentialsProvider,
`${parameters.url}/leaves_many?int64_as_str=1&bounds=${bounds}`,
{
method: "POST",
body: JSON.stringify({
node_ids: [...segments],
}),
},
responseJson,
);
signal.dispatch(response);
console.log(segments.size);
try {
const response = await cancellableFetchSpecialOk(
credentialsProvider,
`${parameters.url}/leaves_many?int64_as_str=1&bounds=${bounds}`,
{
method: "POST",
body: JSON.stringify({
node_ids: [...segments],
}),
},
responseJson,
);
signal.dispatch(response);
} catch (e) {
signal.dispatch(e);
}
}, 0);
}
const [request, segments] = pendingRequest;
segments.add(segment);
return new Promise((f) => {
return new Promise((f, r) => {
const unregister = request.add((response) => {
f(response[segment.toJSON()]);
unregister();
if (response instanceof Error) {
r(response);
} else {
f(response[segment.toJSON()]);
}
});
});
}
Expand Down

0 comments on commit 7b533ff

Please sign in to comment.