Fix long crash stack traces breaking the GitHub URL

This commit is contained in:
Keavon Chambers 2024-01-28 19:25:27 -08:00
parent 6b6accfb91
commit 8a6854e55b
1 changed files with 46 additions and 33 deletions

View File

@ -23,45 +23,58 @@ export function createPanicManager(editor: Editor, dialogState: DialogState) {
export function githubUrl(panicDetails: string): string { export function githubUrl(panicDetails: string): string {
const url = new URL("https://github.com/GraphiteEditor/Graphite/issues/new"); const url = new URL("https://github.com/GraphiteEditor/Graphite/issues/new");
let body = stripIndents` const buildUrl = (includeCrashReport: boolean) => {
**Describe the Crash** let body = stripIndents`
Explain clearly what you were doing when the crash occurred. **Describe the Crash**
Explain clearly what you were doing when the crash occurred.
**Steps To Reproduce** **Steps To Reproduce**
Describe precisely how the crash occurred, step by step, starting with a new editor window. Describe precisely how the crash occurred, step by step, starting with a new editor window.
1. Open the Graphite editor at https://editor.graphite.rs 1. Open the Graphite editor at https://editor.graphite.rs
2. 2.
3. 3.
4. 4.
5. 5.
**Additional Details** **Additional Details**
Provide any further information or context that you think would be helpful in fixing the issue. Screenshots or video can be linked or attached to this issue. Provide any further information or context that you think would be helpful in fixing the issue. Screenshots or video can be linked or attached to this issue.
**Browser and OS** **Browser and OS**
${browserVersion()}, ${operatingSystem(true).replace("Unknown", "YOUR OPERATING SYSTEM")} ${browserVersion()}, ${operatingSystem(true).replace("Unknown", "YOUR OPERATING SYSTEM")}
**Stack Trace** **Stack Trace**
Copied from the crash dialog in the Graphite editor: Copied from the crash dialog in the Graphite editor:
`; `;
body += "\n\n```\n"; const manualCopyStackTraceNotice = stripIndents`
body += panicDetails.trimEnd(); Before submitting this bug, REPLACE THIS WITH THE LOG. Return to the editor and click "Copy Error Log" in the crash dialog and paste it in place of this text.
body += "\n```"; `;
const fields = { body += "\n\n```\n";
title: "[Crash Report] ", body += includeCrashReport ? panicDetails.trimEnd() : manualCopyStackTraceNotice;
body, body += "\n```";
labels: ["Crash"].join(","),
projects: [].join(","), const fields = {
milestone: "", title: "[Crash Report] ",
assignee: "", body,
template: "", labels: ["Crash"].join(","),
projects: [].join(","),
milestone: "",
assignee: "",
template: "",
};
Object.entries(fields).forEach(([field, value]) => {
if (value) url.searchParams.set(field, value);
});
return url.toString();
}; };
Object.entries(fields).forEach(([field, value]) => { let urlString = buildUrl(true);
if (value) url.searchParams.set(field, value); if (urlString.length >= 8192) {
}); // Fall back to a shorter version if it exceeds GitHub limits of 8192 total characters
urlString = buildUrl(false);
return url.toString(); }
return urlString;
} }