From 4766f85b29a1aa73f4b4597f984190f4b77a7f3e Mon Sep 17 00:00:00 2001 From: doubleface Date: Thu, 14 Dec 2023 14:21:19 +0100 Subject: [PATCH] fix: Avoid undefined is not a function error in onWorkerError Also : - check if the launcher is present - log a stringified version of the event in konnector log when possible - or else log stringified version of the event in flagship app console - apply this same logic to onWorkerError, onPilotError, onPilotWebviewKilled, onWorkerWebviewKilled --- src/screens/konnectors/LauncherView.js | 46 +++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/screens/konnectors/LauncherView.js b/src/screens/konnectors/LauncherView.js index 839f2f177..9fe36ca13 100644 --- a/src/screens/konnectors/LauncherView.js +++ b/src/screens/konnectors/LauncherView.js @@ -349,8 +349,15 @@ export class LauncherView extends Component { * @param {Object} event */ onWorkerError({ nativeEvent }) { - log.error('onWorkerError', { nativeEvent }) - this.stop({ message: 'VENDOR_DOWN' }) + if (this.launcher) { + this.launcher.log({ + level: 'error', + msg: 'Worker webview error: ' + JSON.stringify(nativeEvent) + }) + this.launcher.stop({ message: 'VENDOR_DOWN' }) + } else { + log.error('onWorkerError', JSON.stringify(nativeEvent)) + } } /** * When an error is detected in the pilot webview @@ -358,8 +365,15 @@ export class LauncherView extends Component { * @param {Object} event */ onPilotError({ nativeEvent }) { - log.error('onPilotError', { nativeEvent }) - this.stop({ message: 'VENDOR_DOWN' }) + if (this.launcher) { + this.launcher.log({ + level: 'error', + msg: 'Pilot webview error: ' + JSON.stringify(nativeEvent) + }) + this.launcher.stop({ message: 'VENDOR_DOWN' }) + } else { + log.error('onPilotError', JSON.stringify(nativeEvent)) + } } /** * Postmessage relay from the pilot to the launcher @@ -379,10 +393,14 @@ export class LauncherView extends Component { */ onPilotWebviewKilled(syntheticEvent) { const { nativeEvent } = syntheticEvent - this.launcher.log({ - level: 'error', - msg: 'Pilot webview terminated: ' + JSON.stringify(nativeEvent) - }) + if (this.launcher) { + this.launcher.log({ + level: 'error', + msg: 'Pilot webview terminated: ' + JSON.stringify(nativeEvent) + }) + } else { + log.error('onPilotWebviewKilled', JSON.stringify(nativeEvent)) + } } /** * When the worker webview is killed @@ -391,10 +409,14 @@ export class LauncherView extends Component { */ onWorkerWebviewKilled(syntheticEvent) { const { nativeEvent } = syntheticEvent - this.launcher.log({ - level: 'error', - msg: 'Worker webview terminated: ' + JSON.stringify(nativeEvent) - }) + if (this.launcher) { + this.launcher.log({ + level: 'error', + msg: 'Worker webview terminated: ' + JSON.stringify(nativeEvent) + }) + } else { + log.error('onWorkerWebviewKilled', JSON.stringify(nativeEvent)) + } } /** * Postmessage relay from the worker to the launcher