summaryrefslogtreecommitdiff
path: root/frontend/src/errorboundary-hook.tsx
diff options
context:
space:
mode:
authorAAGaming <aagaming@riseup.net>2024-05-27 17:21:27 -0400
committerAAGaming <aagaming@riseup.net>2024-05-27 17:21:27 -0400
commit9c8db576f5cea498c70d00a0764d7f3c6c9cef65 (patch)
tree72436ef52123e6343cdcc21b66efd59b51c4de23 /frontend/src/errorboundary-hook.tsx
parenta84a13c76d99f1e6f4505d43108a4111749e5035 (diff)
downloaddecky-loader-9c8db576f5cea498c70d00a0764d7f3c6c9cef65.tar.gz
decky-loader-9c8db576f5cea498c70d00a0764d7f3c6c9cef65.zip
error boundary now properly reports steam errors
Diffstat (limited to 'frontend/src/errorboundary-hook.tsx')
-rw-r--r--frontend/src/errorboundary-hook.tsx37
1 files changed, 31 insertions, 6 deletions
diff --git a/frontend/src/errorboundary-hook.tsx b/frontend/src/errorboundary-hook.tsx
index 175b3ff6..6963f207 100644
--- a/frontend/src/errorboundary-hook.tsx
+++ b/frontend/src/errorboundary-hook.tsx
@@ -2,6 +2,7 @@ import { Patch, callOriginal, findModuleExport, replacePatch } from '@decky/ui';
import DeckyErrorBoundary from './components/DeckyErrorBoundary';
import Logger from './logger';
+import { getLikelyErrorSourceFromValveError } from './utils/errors';
declare global {
interface Window {
@@ -11,6 +12,7 @@ declare global {
class ErrorBoundaryHook extends Logger {
private errorBoundaryPatch?: Patch;
+ private errorCheckPatch?: Patch;
constructor() {
super('ErrorBoundaryHook');
@@ -35,13 +37,29 @@ class ErrorBoundaryHook extends Logger {
const errorReportingStore = initErrorReportingStore();
// NUH UH.
- Object.defineProperty(Object.getPrototypeOf(errorReportingStore), 'reporting_enabled', {
- get: () => false,
- });
- errorReportingStore.m_bEnabled = false;
+ // Object.defineProperty(Object.getPrototypeOf(errorReportingStore), 'reporting_enabled', {
+ // get: () => false,
+ // });
+ // errorReportingStore.m_bEnabled = false;
// @ts-ignore
- // window.errorStore = errorReportingStore;
+ window.errorStore = errorReportingStore;
+
+ const react15069WorkaroundRegex = / at .+\.componentDidCatch\..+\.callback /;
+ this.errorCheckPatch = replacePatch(Object.getPrototypeOf(errorReportingStore), 'BIsBlacklisted', (args: any[]) => {
+ const [errorSource, wasPlugin, shouldReport] = getLikelyErrorSourceFromValveError(args[0]);
+ this.debug('Caught an error', args, { errorSource, wasPlugin, shouldReport });
+ // react#15069 workaround. this took 2 hours to figure out.
+ if (
+ args[0]?.message?.[3]?.[0] &&
+ args[0]?.message?.[1]?.[0] == ' at console.error ' &&
+ react15069WorkaroundRegex.test(args[0].message[3][0])
+ ) {
+ this.debug('ignoring early report caused by react#15069');
+ return true;
+ }
+ return shouldReport ? callOriginal : true;
+ });
const ValveErrorBoundary = findModuleExport(
(e) => e.InstallErrorReportingStore && e?.prototype?.Reset && e?.prototype?.componentDidCatch,
@@ -53,8 +71,14 @@ class ErrorBoundaryHook extends Logger {
this.errorBoundaryPatch = replacePatch(ValveErrorBoundary.prototype, 'render', function (this: any) {
if (this.state.error) {
+ const store = Object.getPrototypeOf(this)?.constructor?.sm_ErrorReportingStore || errorReportingStore;
return (
- <DeckyErrorBoundary error={this.state.error} errorKey={this.state.errorKey} reset={() => this.Reset()} />
+ <DeckyErrorBoundary
+ error={this.state.error}
+ errorKey={this.props.errorKey}
+ identifier={`${store.product}_${store.version}_${this.state.identifierHash}`}
+ reset={() => this.Reset()}
+ />
);
}
return callOriginal;
@@ -62,6 +86,7 @@ class ErrorBoundaryHook extends Logger {
}
deinit() {
+ this.errorCheckPatch?.unpatch();
this.errorBoundaryPatch?.unpatch();
}
}