Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree item abort #6757

Merged
merged 18 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions e2e/tests/functional/tree.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,47 @@ test.describe('Main Tree', () => {
]);
});
});
test('Opening and closing an item before the request has been fulfilled will abort the request @couchdb', async ({
page,
openmctConfig
}) => {
const { myItemsFolderName } = openmctConfig;
let requestWasAborted = false;

page.on('requestfailed', (request) => {
// check if the request was aborted
console.log('request error text', request.failure().errorText);
if (request.failure().errorText === 'net::ERR_ABORTED') {
requestWasAborted = true;
}
});

const fooData = await createDomainObjectWithDefaults(page, {
type: 'Folder',
name: 'Foo'
});

// Intercept and delay request
const delayInMs = 500;

await page.route('**', async (route, request) => {
console.log('request ', request.url(), request.url().endsWith(fooData.uuid));
await new Promise((resolve) => setTimeout(resolve, delayInMs));

route.continue();
});

// Quickly Expand/close the root folder
const mainTree = page.getByRole('tree', {
name: 'Main Tree'
});
const treeItem = mainTree.getByRole('treeitem', {
myItemsFolderName
});
await treeItem.locator('.c-disclosure-triangle').dblclick({ delay: 400 });
jvigliotta marked this conversation as resolved.
Show resolved Hide resolved

expect(requestWasAborted).toBe(true);
});
});

/**
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/persistence/couch/CouchObjectProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,17 @@
// Network error, CouchDB unreachable.
jvigliotta marked this conversation as resolved.
Show resolved Hide resolved
if (response === null) {
this.indicator.setIndicatorToState(DISCONNECTED);
console.error(error.message);

if (!error.name === 'AbortError') {
Fixed Show fixed Hide fixed
console.error(error.message);

Check warning on line 228 in src/plugins/persistence/couch/CouchObjectProvider.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/persistence/couch/CouchObjectProvider.js#L228

Added line #L228 was not covered by tests
}

throw new Error(`CouchDB Error - No response"`);
} else {
if (body?.model && isNotebookOrAnnotationType(body.model)) {
// warn since we handle conflicts for notebooks
console.warn(error.message);
} else {
} else if (!error.name === 'AbortError') {

Check warning on line 236 in src/plugins/persistence/couch/CouchObjectProvider.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/persistence/couch/CouchObjectProvider.js#L236

Added line #L236 was not covered by tests
Fixed Show fixed Hide fixed
console.error(error.message);
}

Expand Down
5 changes: 3 additions & 2 deletions src/ui/layout/mct-tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,13 @@
},
async openTreeItem(parentItem) {
const parentPath = parentItem.navigationPath;
const abortSignal = this.startItemLoad(parentPath);

Check warning on line 329 in src/ui/layout/mct-tree.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/layout/mct-tree.vue#L329

Added line #L329 was not covered by tests

this.startItemLoad(parentPath);
// pass in abort signal when functional
const childrenItems = await this.loadAndBuildTreeItemsFor(
parentItem.object.identifier,
parentItem.objectPath
parentItem.objectPath,
abortSignal
);
const parentIndex = this.treeItems.indexOf(parentItem);

Expand Down