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

Shared - jolokiaService should resolve or reject requests in case of ajax error #635

Open
tadayosi opened this issue Oct 26, 2023 · 2 comments
Labels
area/shared kind/enhancement Enhancements that don't necessarily result in a new feature

Comments

@tadayosi
Copy link
Member

Currently the operations provided by jolokiaService such as readAttribute, writeAttribute, execute, search, etc. rely on the default ajaxError callback in case of ajax error happening while performing Jolokia requests.

return (xhr: JQueryXHR) => {
switch (xhr.status) {
case 401:
case 403: {
const url = new URL(window.location.href)
// If window was opened to connect to remote Jolokia endpoint
if (url.searchParams.has(PARAM_KEY_CONNECTION)) {
// ... and not showing the login modal
if (url.pathname !== '/connect/login') {
this.jolokia?.then(jolokia => jolokia.stop())
const redirectUrl = window.location.href
url.pathname = '/connect/login'
url.searchParams.append('redirect', redirectUrl)
window.location.href = url.href
}
} else {
// just logout
userService.isLogin().then(login => {
log.debug('Logging out due to jQuery ajax error: status =', xhr.status)
login && userService.logout()
})
}
break
}
default: {
errorCount++
const updateRate = this.loadUpdateRate()
const validityPeriod = updateRate * (errorThreshold + 1)
setTimeout(() => errorCount--, validityPeriod)
if (errorCount > errorThreshold) {
eventService.notify({
type: 'danger',
message: 'Connection lost. Retrying...',
// -100ms is to not overlap between update and notification
duration: updateRate - 100,
})
}
}
}
}

Since this callback is not aware of resolve or reject callback provided by each Promise that wraps a Jolokia operation, the processing of the request should hang in case of ajax error. This can happen when for some reason the remote Jolokia endpoint starts to stop serving requests, for instance due to authentication being expired or any other internal server error.

This should be actually mostly fine, because then the user would need to refresh the page or authenticate again to restore the working status anyway. So, practically we've observed no issues with it yet. However, it should be still considered well-behaved to make sure the operation terminates in such an exceptional case. That's why it's marked as enhancement.

@tadayosi tadayosi added kind/enhancement Enhancements that don't necessarily result in a new feature area/shared labels Oct 26, 2023
@grgrzybek grgrzybek self-assigned this Apr 2, 2024
@grgrzybek
Copy link
Contributor

Hmm, I was thinking about it, but maybe it should be more long term goal - including Jolokia switch to Fetch API? (jolokia/jolokia#580)...

@grgrzybek grgrzybek removed their assignment May 21, 2024
@tadayosi
Copy link
Member Author

tadayosi commented May 21, 2024

@grgrzybek If I remember it correctly, the issue was filed right after this fix: 4963ed3
it already fixed the issue for the list operation. What we need to do would be to apply the similar fix to the rest of Jolokia operations. So I think it can be fixed in a short term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/shared kind/enhancement Enhancements that don't necessarily result in a new feature
Projects
Status: Backlog
Development

No branches or pull requests

2 participants