Skip to content

Commit adcb528

Browse files
authored
Sentry bugrun (codesandbox#527)
* Fix sentry bugs * Fix nullpointers * Fix wrong path
1 parent ff3bef0 commit adcb528

File tree

8 files changed

+39
-31
lines changed

8 files changed

+39
-31
lines changed

packages/app/src/app/components/NewSandbox/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function NewSandbox({ signals }) {
4949
height={50}
5050
text="React"
5151
href={newSandboxUrl()}
52-
onClick={() => signals.editor.newSandboxModalClosed()}
52+
onClick={() => signals.closeModal()}
5353
/>
5454

5555
<Logo
@@ -58,7 +58,7 @@ function NewSandbox({ signals }) {
5858
height={50}
5959
text="Vue"
6060
href={newVueSandboxUrl()}
61-
onClick={() => signals.editor.newSandboxModalClosed()}
61+
onClick={() => signals.closeModal()}
6262
/>
6363

6464
<Logo
@@ -67,47 +67,47 @@ function NewSandbox({ signals }) {
6767
height={50}
6868
text="Angular"
6969
href={newAngularSandboxUrl()}
70-
onClick={() => signals.editor.newSandboxModalClosed()}
70+
onClick={() => signals.closeModal()}
7171
/>
7272
<Logo
7373
Icon={PreactIcon}
7474
width={50}
7575
height={50}
7676
text="Preact"
7777
href={newPreactSandboxUrl()}
78-
onClick={() => signals.editor.newSandboxModalClosed()}
78+
onClick={() => signals.closeModal()}
7979
/>
8080
<Logo
8181
Icon={SvelteIcon}
8282
width={50}
8383
height={50}
8484
text="Svelte"
8585
href={newSvelteSandboxUrl()}
86-
onClick={() => signals.editor.newSandboxModalClosed()}
86+
onClick={() => signals.closeModal()}
8787
/>
8888
<Logo
8989
Icon={ReactIcon}
9090
width={50}
9191
height={50}
9292
text="React TypeScript"
9393
href={newReactTypeScriptSandboxUrl()}
94-
onClick={() => signals.editor.newSandboxModalClosed()}
94+
onClick={() => signals.closeModal()}
9595
/>
9696
<Logo
9797
Icon={GithubIcon}
9898
width={50}
9999
height={50}
100100
text="Import from Github"
101101
href={importFromGitHubUrl()}
102-
onClick={() => signals.editor.newSandboxModalClosed()}
102+
onClick={() => signals.closeModal()}
103103
/>
104104
<Logo
105105
Icon={TerminalIcon}
106106
width={50}
107107
height={50}
108108
text="Upload from CLI"
109109
href={uploadFromCliUrl()}
110-
onClick={() => signals.editor.newSandboxModalClosed()}
110+
onClick={() => signals.closeModal()}
111111
/>
112112
</RowContainer>
113113
</Container>

packages/app/src/app/pages/Sandbox/Editor/Content/Tabs/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class EditorTabs extends React.Component {
4343
closeListener = e => {
4444
if ((e.ctrlKey || e.metaKey) && e.keyCode === 87) {
4545
e.preventDefault();
46-
const currentPos = this.props.tabs.findIndex(
47-
t => t.moduleId === this.props.currentModuleId
48-
);
46+
const currentPos = this.props.tabs
47+
.filter(x => x)
48+
.findIndex(t => t.moduleId === this.props.currentModuleId);
4949
this.closeTab(currentPos);
5050
}
5151
};

packages/app/src/app/store/factories.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export function setCurrentModuleById(id) {
4242
moduleEntry => moduleEntry.id === resolve.value(id)
4343
);
4444

45-
state.set('editor.currentModuleShortid', module.shortid);
45+
if (module) {
46+
state.set('editor.currentModuleShortid', module.shortid);
47+
}
4648
};
4749
}
4850

packages/app/src/app/store/modules/editor/actions.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,27 @@ export function renameModuleFromPreview({ state, props, utils }) {
134134

135135
export function addErrorFromPreview({ state, props, utils }) {
136136
const sandbox = state.get('editor.currentSandbox');
137-
const module = utils.resolveModule(
138-
props.action.path.replace(/^\//, ''),
139-
sandbox.modules,
140-
sandbox.directories
141-
);
142-
const error = {
143-
moduleId: module.id,
144-
column: props.action.column,
145-
line: props.action.line,
146-
message: props.action.message,
147-
title: props.action.title,
148-
};
149137

150-
if (module) {
151-
state.push('editor.errors', error);
138+
try {
139+
const module = utils.resolveModule(
140+
props.action.path.replace(/^\//, ''),
141+
sandbox.modules,
142+
sandbox.directories
143+
);
144+
145+
const error = {
146+
moduleId: module.id,
147+
column: props.action.column,
148+
line: props.action.line,
149+
message: props.action.message,
150+
title: props.action.title,
151+
};
152+
153+
if (module) {
154+
state.push('editor.errors', error);
155+
}
156+
} catch (e) {
157+
/* ignore, module not found */
152158
}
153159
}
154160

packages/app/src/app/store/modules/git/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { types } from 'mobx-state-tree';
33
const Git = types.model({
44
branch: types.string,
55
commitSha: types.string,
6-
path: types.string,
6+
path: types.maybe(types.string),
77
repo: types.string,
88
username: types.string,
99
});

packages/app/src/app/store/modules/git/sequences.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const createRepo = [
2222
set(state`currentModal`, null),
2323
actions.redirectToGithubSandbox,
2424
],
25-
false: set(state`git.error`, props`error`),
25+
error: set(state`git.error`, props`error`),
2626
},
2727
];
2828

packages/app/src/app/store/modules/profile/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default {
2222
showcasedSandboxShortid: types.maybe(types.string),
2323
sandboxCount: types.number,
2424
receivedLikeCount: types.number,
25-
name: types.string,
25+
name: types.maybe(types.string),
2626
id: types.string,
2727
givenLikeCount: types.number,
2828
forkedCount: types.number,

standalone-packages/codesandbox-browserfs/src/backend/CodeSandboxFS.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export default class CodeSandboxFS extends SynchronousFileSystem
198198
};
199199
this.manager.addModule(module);
200200

201-
const buffer = Buffer.from(module.code);
201+
const buffer = Buffer.from(module.code || '');
202202
const stats = new Stats(FileType.FILE, buffer.length);
203203

204204
return new CodeSandboxFile(this, p, flag, stats, buffer);
@@ -212,7 +212,7 @@ export default class CodeSandboxFS extends SynchronousFileSystem
212212
}
213213

214214
const { code = '' } = moduleInfo.module;
215-
const buffer = Buffer.from(code);
215+
const buffer = Buffer.from(code || '');
216216
const stats = new Stats(FileType.FILE, buffer.length);
217217

218218
return new CodeSandboxFile(this, p, flag, stats, buffer);

0 commit comments

Comments
 (0)