mirror of
https://github.com/nasa/openmct.git
synced 2025-03-22 03:55:31 +00:00
Fix couchdb no response (#5474)
* Update the creation date only when the document is created for the first time * If there is no response from a bulk get, couch db has issues * Check the response - if it's null, don't apply interceptors
This commit is contained in:
parent
e9c0909415
commit
0af7965021
@ -233,7 +233,11 @@ export default class ObjectAPI {
|
||||
|
||||
delete this.cache[keystring];
|
||||
|
||||
result = this.applyGetInterceptors(identifier);
|
||||
if (!result) {
|
||||
//no result means resource either doesn't exist or is missing
|
||||
//otherwise it's an error, and we shouldn't apply interceptors
|
||||
result = this.applyGetInterceptors(identifier);
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
@ -45,8 +45,7 @@ export default function CouchDocument(id, model, rev, markDeleted) {
|
||||
"category": "domain object",
|
||||
"type": model.type,
|
||||
"owner": "admin",
|
||||
"name": model.name,
|
||||
"created": Date.now()
|
||||
"name": model.name
|
||||
},
|
||||
"model": model
|
||||
};
|
||||
|
@ -215,6 +215,8 @@ class CouchObjectProvider {
|
||||
// Network error, CouchDB unreachable.
|
||||
if (response === null) {
|
||||
this.indicator.setIndicatorToState(DISCONNECTED);
|
||||
console.error(error.message);
|
||||
throw new Error(`CouchDB Error - No response"`);
|
||||
}
|
||||
|
||||
console.error(error.message);
|
||||
@ -379,6 +381,8 @@ class CouchObjectProvider {
|
||||
return this.request(ALL_DOCS, 'POST', query, signal).then((response) => {
|
||||
if (response && response.rows !== undefined) {
|
||||
return response.rows.reduce((map, row) => {
|
||||
//row.doc === null if the document does not exist.
|
||||
//row.doc === undefined if the document is not found.
|
||||
if (row.doc !== undefined) {
|
||||
map[row.key] = this.#getModel(row.doc);
|
||||
}
|
||||
@ -647,6 +651,7 @@ class CouchObjectProvider {
|
||||
this.objectQueue[key].pending = true;
|
||||
const queued = this.objectQueue[key].dequeue();
|
||||
let document = new CouchDocument(key, queued.model);
|
||||
document.metadata.created = Date.now();
|
||||
this.request(key, "PUT", document).then((response) => {
|
||||
console.log('create check response', key);
|
||||
this.#checkResponse(response, queued.intermediateResponse, key);
|
||||
|
Loading…
x
Reference in New Issue
Block a user