mirror of
https://github.com/nasa/openmct.git
synced 2024-12-23 23:12:23 +00:00
Handled chunked response from CouchDB for search results (#3701)
This commit is contained in:
parent
169eec0a51
commit
15778b00a0
@ -145,7 +145,8 @@ export default class CouchObjectProvider {
|
||||
|
||||
const reader = response.body.getReader();
|
||||
let completed = false;
|
||||
|
||||
let decoder = new TextDecoder("utf-8");
|
||||
let decodedChunk = '';
|
||||
while (!completed) {
|
||||
const {done, value} = await reader.read();
|
||||
//done is true when we lose connection with the provider
|
||||
@ -156,7 +157,11 @@ export default class CouchObjectProvider {
|
||||
if (value) {
|
||||
let chunk = new Uint8Array(value.length);
|
||||
chunk.set(value, 0);
|
||||
const decodedChunk = new TextDecoder("utf-8").decode(chunk);
|
||||
const partial = decoder.decode(chunk, {stream: !completed});
|
||||
decodedChunk = decodedChunk + partial;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const json = JSON.parse(decodedChunk);
|
||||
if (json) {
|
||||
@ -171,9 +176,6 @@ export default class CouchObjectProvider {
|
||||
} catch (e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user