fix core dump screenshot (#2911)

* fix core dump screenshot

* make it robust
This commit is contained in:
Kurt Hutten
2024-07-04 15:58:29 +10:00
committed by GitHub
parent 6370d45f94
commit 0dfee64e3b
7 changed files with 18 additions and 44 deletions

View File

@ -10,7 +10,6 @@ import {
import { APP_VERSION } from 'routes/Settings'
import { UAParser } from 'ua-parser-js'
import screenshot from 'lib/screenshot'
import React from 'react'
import { VITE_KC_API_BASE_URL } from 'env'
/* eslint-disable suggest-no-throw/suggest-no-throw --
@ -33,17 +32,14 @@ import { VITE_KC_API_BASE_URL } from 'env'
// TODO: Throw more
export class CoreDumpManager {
engineCommandManager: EngineCommandManager
htmlRef: React.RefObject<HTMLDivElement> | null
token: string | undefined
baseUrl: string = VITE_KC_API_BASE_URL
constructor(
engineCommandManager: EngineCommandManager,
htmlRef: React.RefObject<HTMLDivElement> | null,
token: string | undefined
) {
this.engineCommandManager = engineCommandManager
this.htmlRef = htmlRef
this.token = token
}
@ -449,12 +445,11 @@ export class CoreDumpManager {
// Return a data URL (png format) of the screenshot of the current page.
screenshot(): Promise<string> {
return screenshot(this.htmlRef)
.then((screenshot: string) => {
return screenshot
})
.catch((error: any) => {
throw new Error(`Error getting screenshot: ${error}`)
})
return (
screenshot()
.then((screenshotStr: string) => screenshotStr)
// maybe rust should handle an error, but an empty string at least doesn't cause the core dump to fail entirely
.catch((error: any) => ``)
)
}
}