Catch render() errors from the progress-listener callback (AI)
The onArticlesProgress listener invoked async render() without awaiting or catching it, unlike the final render() call, which is inside a try/catch. A mid-crawl render failure was an unhandled rejection that left the list stuck on its loading state forever instead of showing articlesLoadError. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d424ffbc9
commit
cf2733368f
1 file changed
+9
-2
+9
-2
@@ -284,12 +284,19 @@ export async function loadArticleList(filter = null, page = 1) {
|
||||
}
|
||||
};
|
||||
|
||||
const unsubscribe = onArticlesProgress((partialArticles, done) => { render(partialArticles, done); });
|
||||
// Same error handling as the final render below (not just the same
|
||||
// message — an error thrown here, e.g. a malformed template, would
|
||||
// otherwise be an unhandled rejection that leaves the list stuck on its
|
||||
// loading state instead of ever showing articlesLoadError).
|
||||
const showRenderError = error => {
|
||||
if (generation === currentGeneration) view.innerHTML = `<p class="error">${t('articlesLoadError', { message: error.message })}</p>`;
|
||||
};
|
||||
const unsubscribe = onArticlesProgress((partialArticles, done) => { render(partialArticles, done).catch(showRenderError); });
|
||||
try {
|
||||
const allArticles = await discoverArticles();
|
||||
await render(allArticles, true);
|
||||
} catch (error) {
|
||||
if (generation === currentGeneration) view.innerHTML = `<p class="error">${t('articlesLoadError', { message: error.message })}</p>`;
|
||||
showRenderError(error);
|
||||
} finally {
|
||||
unsubscribe();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user