Skip to content

Commit 1f13b87

Browse files
committed
fix: Handle additional drop and monaco errors
https://harperdb.atlassian.net/browse/STUDIO-616
1 parent 0c46fd8 commit 1f13b87

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/features/instance/applications/components/ApplicationsSidebar/DropTarget.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,15 @@ ${humanFileSize(uploadedBytes)} of ${humanFileSize(totalBytes)}`,
114114

115115
const filePath = getFilePath(targetPath, file);
116116
const dataURLResponse = await readAsDataURL(file);
117-
const dataURLResult = dataURLResponse.target!.result as string;
117+
const dataURLResult = dataURLResponse.target?.result as string | undefined;
118+
if (!dataURLResult) {
119+
throw new Error(`Failed to read file: ${file.name}`);
120+
}
118121
const demarcation = 'base64,';
119122
const encodingIndex = dataURLResult.indexOf(demarcation);
123+
if (encodingIndex === -1) {
124+
throw new Error(`Invalid data URL format for file: ${file.name}`);
125+
}
120126
if (!canceled) {
121127
await setComponentFile({
122128
...instanceParams,

src/lib/monaco/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
4949
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
5050
import yamlWorker from 'monaco-yaml/yaml.worker?worker';
5151

52-
const globalScope = self as unknown as { MonacoEnvironment?: monaco.Environment };
52+
const globalScope = globalThis as unknown as { MonacoEnvironment?: monaco.Environment };
5353

5454
globalScope.MonacoEnvironment = {
5555
getWorker(_workerId: string, label: string): Worker {

0 commit comments

Comments
 (0)