fix: contain asynchronous BPM route failures to prevent service crashes

This commit is contained in:
阿白叔 committed 2026-10-18 08:31:12 +08:00
1 parent 3363a88abf
commit e2bd8c390f
3 files changed
+33 -4

No files matched your search

+6 -4
View File
@@ -223,7 +223,7 @@ class BpmSessionManager {
try {
// A popup is never a remote-control surface. Block its first navigation,
// before even an allowed host can redirect it elsewhere.
if (route.request().isNavigationRequest() && route.request().frame().page()!==lease.page) return route.abort('blockedbyclient');
if (route.request().isNavigationRequest() && route.request().frame().page()!==lease.page) return await route.abort('blockedbyclient');
if (this.allowed(route.request().url())) {
// route.continue follows redirects without re-entering the route handler.
// Inspect each redirect before Chromium receives it, including resource redirects.
@@ -231,10 +231,12 @@ class BpmSessionManager {
const location=response.headers().location;
if (location && response.status()>=300 && response.status()<400 && !this.allowed(new URL(location,route.request().url()).href)) {
if (route.request().isNavigationRequest() && !route.request().frame().parentFrame()) lease.blocked=true;
return route.abort('blockedbyclient');
return await route.abort('blockedbyclient');
}
if (/attachment/i.test(response.headers()['content-disposition']||'')) return route.abort('blockedbyclient');
return route.fulfill({response});
if (/attachment/i.test(response.headers()['content-disposition']||'')) return await route.abort('blockedbyclient');
// Await inside this try: closing a context can dispose the fetched response
// before fulfill finishes. Returning its promise bypasses this catch.
return await route.fulfill({response});
}
if (route.request().isNavigationRequest() && !route.request().frame().parentFrame()) lease.blocked = true;
await route.abort('blockedbyclient');