Stricitfy rageshake (#10389)

This commit is contained in:
Michael Weimann 2023-03-15 18:32:31 +01:00 committed by GitHub
parent a4262cd8cf
commit 37d218eb61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 20 deletions

View file

@ -64,7 +64,8 @@ export class ConsoleLogger {
warn: "W", warn: "W",
error: "E", error: "E",
} as const; } as const;
Object.keys(consoleFunctionsToLevels).forEach((fnName: keyof typeof consoleFunctionsToLevels) => { (Object.keys(consoleFunctionsToLevels) as [keyof typeof consoleFunctionsToLevels]).forEach(
(fnName: keyof typeof consoleFunctionsToLevels) => {
const level = consoleFunctionsToLevels[fnName]; const level = consoleFunctionsToLevels[fnName];
const originalFn = consoleObj[fnName].bind(consoleObj); const originalFn = consoleObj[fnName].bind(consoleObj);
this.originalFunctions[fnName] = originalFn; this.originalFunctions[fnName] = originalFn;
@ -72,7 +73,8 @@ export class ConsoleLogger {
this.log(level, ...args); this.log(level, ...args);
originalFn(...args); originalFn(...args);
}; };
}); },
);
} }
public bypassRageshake(fnName: LogFunctionName, ...args: (Error | DOMException | object | string)[]): void { public bypassRageshake(fnName: LogFunctionName, ...args: (Error | DOMException | object | string)[]): void {
@ -261,6 +263,8 @@ export class IndexedDBLogStore {
// Returns: a string representing the concatenated logs for this ID. // Returns: a string representing the concatenated logs for this ID.
// Stops adding log fragments when the size exceeds maxSize // Stops adding log fragments when the size exceeds maxSize
function fetchLogs(id: string, maxSize: number): Promise<string> { function fetchLogs(id: string, maxSize: number): Promise<string> {
if (!db) return Promise.reject("DB unavailable");
const objectStore = db.transaction("logs", "readonly").objectStore("logs"); const objectStore = db.transaction("logs", "readonly").objectStore("logs");
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -287,6 +291,8 @@ export class IndexedDBLogStore {
// Returns: A sorted array of log IDs. (newest first) // Returns: A sorted array of log IDs. (newest first)
function fetchLogIds(): Promise<string[]> { function fetchLogIds(): Promise<string[]> {
if (!db) return Promise.reject("DB unavailable");
// To gather all the log IDs, query for all records in logslastmod. // To gather all the log IDs, query for all records in logslastmod.
const o = db.transaction("logslastmod", "readonly").objectStore("logslastmod"); const o = db.transaction("logslastmod", "readonly").objectStore("logslastmod");
return selectQuery(o, undefined, (cursor) => { return selectQuery(o, undefined, (cursor) => {
@ -305,6 +311,8 @@ export class IndexedDBLogStore {
} }
function deleteLogs(id: string): Promise<void> { function deleteLogs(id: string): Promise<void> {
if (!db) return Promise.reject("DB unavailable");
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
const txn = db.transaction(["logs", "logslastmod"], "readwrite"); const txn = db.transaction(["logs", "logslastmod"], "readwrite");
const o = txn.objectStore("logs"); const o = txn.objectStore("logs");

View file

@ -88,7 +88,7 @@ async function collectBugReport(opts: IOpts = {}, gzipLogs = true): Promise<Form
keys.push(`curve25519:${client.getDeviceCurve25519Key()}`); keys.push(`curve25519:${client.getDeviceCurve25519Key()}`);
} }
body.append("device_keys", keys.join(", ")); body.append("device_keys", keys.join(", "));
body.append("cross_signing_key", client.getCrossSigningId()); body.append("cross_signing_key", client.getCrossSigningId() ?? "n/a");
// add cross-signing status information // add cross-signing status information
const crossSigning = client.crypto.crossSigningInfo; const crossSigning = client.crypto.crossSigningInfo;
@ -99,7 +99,7 @@ async function collectBugReport(opts: IOpts = {}, gzipLogs = true): Promise<Form
"cross_signing_supported_by_hs", "cross_signing_supported_by_hs",
String(await client.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")), String(await client.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")),
); );
body.append("cross_signing_key", crossSigning.getId()); body.append("cross_signing_key", crossSigning.getId() ?? "n/a");
body.append( body.append(
"cross_signing_privkey_in_secret_storage", "cross_signing_privkey_in_secret_storage",
String(!!(await crossSigning.isStoredInSecretStorage(secretStorage))), String(!!(await crossSigning.isStoredInSecretStorage(secretStorage))),
@ -108,15 +108,15 @@ async function collectBugReport(opts: IOpts = {}, gzipLogs = true): Promise<Form
const pkCache = client.getCrossSigningCacheCallbacks(); const pkCache = client.getCrossSigningCacheCallbacks();
body.append( body.append(
"cross_signing_master_privkey_cached", "cross_signing_master_privkey_cached",
String(!!(pkCache && (await pkCache.getCrossSigningKeyCache("master")))), String(!!(pkCache && (await pkCache?.getCrossSigningKeyCache?.("master")))),
); );
body.append( body.append(
"cross_signing_self_signing_privkey_cached", "cross_signing_self_signing_privkey_cached",
String(!!(pkCache && (await pkCache.getCrossSigningKeyCache("self_signing")))), String(!!(pkCache && (await pkCache?.getCrossSigningKeyCache?.("self_signing")))),
); );
body.append( body.append(
"cross_signing_user_signing_privkey_cached", "cross_signing_user_signing_privkey_cached",
String(!!(pkCache && (await pkCache.getCrossSigningKeyCache("user_signing")))), String(!!(pkCache && (await pkCache?.getCrossSigningKeyCache?.("user_signing")))),
); );
body.append("secret_storage_ready", String(await client.isSecretStorageReady())); body.append("secret_storage_ready", String(await client.isSecretStorageReady()));
@ -163,14 +163,14 @@ async function collectBugReport(opts: IOpts = {}, gzipLogs = true): Promise<Form
body.append("storageManager_usage", String(estimate.usage)); body.append("storageManager_usage", String(estimate.usage));
if (estimate.usageDetails) { if (estimate.usageDetails) {
Object.keys(estimate.usageDetails).forEach((k) => { Object.keys(estimate.usageDetails).forEach((k) => {
body.append(`storageManager_usage_${k}`, String(estimate.usageDetails[k])); body.append(`storageManager_usage_${k}`, String(estimate.usageDetails![k]));
}); });
} }
} catch (e) {} } catch (e) {}
} }
if (window.Modernizr) { if (window.Modernizr) {
const missingFeatures = Object.keys(window.Modernizr).filter( const missingFeatures = (Object.keys(window.Modernizr) as [keyof ModernizrStatic]).filter(
(key: keyof ModernizrStatic) => window.Modernizr[key] === false, (key: keyof ModernizrStatic) => window.Modernizr[key] === false,
); );
if (missingFeatures.length > 0) { if (missingFeatures.length > 0) {
@ -253,7 +253,7 @@ export async function downloadBugReport(opts: IOpts = {}): Promise<void> {
await new Promise<void>((resolve) => { await new Promise<void>((resolve) => {
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener("loadend", (ev) => { reader.addEventListener("loadend", (ev) => {
tape.append(`log-${i++}.log`, new TextDecoder().decode(ev.target.result as ArrayBuffer)); tape.append(`log-${i++}.log`, new TextDecoder().decode(reader.result as ArrayBuffer));
resolve(); resolve();
}); });
reader.readAsArrayBuffer(value as Blob); reader.readAsArrayBuffer(value as Blob);
@ -302,14 +302,18 @@ export async function submitFeedback(
body.append("app", "element-web"); body.append("app", "element-web");
body.append("version", version || "UNKNOWN"); body.append("version", version || "UNKNOWN");
body.append("platform", PlatformPeg.get().getHumanReadableName()); body.append("platform", PlatformPeg.get()?.getHumanReadableName() ?? "n/a");
body.append("user_id", MatrixClientPeg.get()?.getUserId()); body.append("user_id", MatrixClientPeg.get()?.getUserId() ?? "n/a");
for (const k in extraData) { for (const k in extraData) {
body.append(k, JSON.stringify(extraData[k])); body.append(k, JSON.stringify(extraData[k]));
} }
await submitReport(SdkConfig.get().bug_report_endpoint_url, body, () => {}); const bugReportEndpointUrl = SdkConfig.get().bug_report_endpoint_url;
if (bugReportEndpointUrl) {
await submitReport(bugReportEndpointUrl, body, () => {});
}
} }
function submitReport(endpoint: string, body: FormData, progressCallback: (str: string) => void): Promise<string> { function submitReport(endpoint: string, body: FormData, progressCallback: (str: string) => void): Promise<string> {