Skip to content

Commit 7283034

Browse files
lbogdanCompuIves
authored andcommitted
Fix spurious console errors (codesandbox#1689)
* Fix spurious console errors. * More removed console.logs * Remove more spurious logs * Remove unneeded code.
1 parent 562f65a commit 7283034

File tree

20 files changed

+60
-53
lines changed

20 files changed

+60
-53
lines changed

packages/app/src/app/components/CodeEditor/VSCode/index.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { render } from 'react-dom';
44
import { ThemeProvider } from 'styled-components';
55
import { TextOperation } from 'ot';
66
import { debounce } from 'lodash-es';
7-
import { getModulePath, resolveModule } from '@codesandbox/common/lib/sandbox/modules';
7+
import {
8+
getModulePath,
9+
resolveModule,
10+
} from '@codesandbox/common/lib/sandbox/modules';
811
import { listen } from 'codesandbox-api';
912

1013
import prettify from 'app/src/app/utils/prettify';
@@ -254,11 +257,16 @@ class MonacoEditor extends React.Component<Props> implements Editor {
254257
this.modelAddedListener = this.editor.textFileService.modelService.onModelAdded(
255258
model => {
256259
if (this.modelListeners[model.uri.path] === undefined) {
257-
const module = resolveModule(
258-
model.uri.path.replace(/^\/sandbox/, ''),
259-
this.sandbox.modules,
260-
this.sandbox.directories
261-
);
260+
let module: Module;
261+
try {
262+
module = resolveModule(
263+
model.uri.path.replace(/^\/sandbox/, ''),
264+
this.sandbox.modules,
265+
this.sandbox.directories
266+
);
267+
} catch (e) {
268+
return;
269+
}
262270

263271
const listener = model.onDidChangeContent(e => {
264272
const path = model.uri.path;

packages/app/src/app/components/Preview/DevTools/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@ export default class DevTools extends React.PureComponent<Props, State> {
436436
>
437437
{!hideTabs && (
438438
<Header
439-
onTouchStart={!primary && this.handleTouchStart}
440-
onMouseDown={!primary && this.handleMouseDown}
439+
onTouchStart={!primary ? this.handleTouchStart : undefined}
440+
onMouseDown={!primary ? this.handleMouseDown : undefined}
441441
primary={primary}
442442
open={!this.state.hidden}
443443
>

packages/app/src/app/pages/Dashboard/Sidebar/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import history from 'app/utils/history';
33
import { inject, observer } from 'mobx-react';
4-
import { Route } from 'react-router-dom';
4+
import { Route, withRouter } from 'react-router-dom';
55
import { Query } from 'react-apollo';
66
import Input from '@codesandbox/common/lib/components/Input';
77
import { Button } from '@codesandbox/common/lib/components/Button';
@@ -17,12 +17,6 @@ import { Items, CategoryHeader, SidebarStyled, InputWrapper } from './elements';
1717
import { TEAMS_QUERY } from '../queries';
1818

1919
class Sidebar extends React.Component {
20-
shouldComponentUpdate() {
21-
// Without this the app won't update on route changes, we've tried using
22-
// `withRouter`, but it caused the app to remount on every route change.
23-
return true;
24-
}
25-
2620
handleSearchFocus = () => {
2721
history.push('/dashboard/search');
2822
};
@@ -129,4 +123,4 @@ class Sidebar extends React.Component {
129123
}
130124
}
131125

132-
export default inject('signals', 'store')(observer(Sidebar));
126+
export default inject('signals', 'store')(withRouter(observer(Sidebar)));

packages/app/src/app/pages/Sandbox/Editor/Workspace/Dependencies/VersionEntry/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ export default class VersionEntry extends React.PureComponent {
4747

4848
getSizeForPKG(pkg) {
4949
fetch(`https://bundlephobia.com/api/size?package=${pkg}`)
50-
.then(response => response.json())
50+
.then(response => {
51+
if (!response.ok) {
52+
throw new Error('Bad request');
53+
}
54+
55+
return response.json();
56+
})
5157
.then(size =>
5258
this.setState({
5359
size,

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/More/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Props = {
1616
const NOT_OWNED_MESSAGE = `Fork this sandbox to make deployments, commit to GitHub, create live sessions with others and more!`;
1717
const NOT_SIGNED_IN_MESSAGE = `Sign in to be able to organize your sandboxes with a dashboard, make deployments, collaborate live with others, make commits to GitHub and more!`;
1818

19-
class More extends React.PureComponent<Props> {
19+
class More extends React.Component<Props> {
2020
componentDidMount() {
2121
track('Workspace - More Opened');
2222
}

packages/app/src/app/pages/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as React from 'react';
33
import { inject, observer } from 'mobx-react';
44
import Loadable from 'app/utils/Loadable';
5-
import { Route, Switch, Redirect } from 'react-router-dom';
5+
import { Route, Switch, Redirect, withRouter } from 'react-router-dom';
66

77
import _debug from '@codesandbox/common/lib/utils/debug';
88
import Notifications from 'app/pages/common/Notifications';
@@ -61,12 +61,6 @@ class Routes extends React.Component<Props> {
6161
this.props.signals.appUnmounted();
6262
}
6363

64-
shouldComponentUpdate() {
65-
// Without this the app won't update on route changes, we've tried using
66-
// `withRouter`, but it caused the app to remount on every route change.
67-
return true;
68-
}
69-
7064
render() {
7165
return (
7266
<Container>
@@ -114,5 +108,5 @@ class Routes extends React.Component<Props> {
114108
}
115109

116110
export default inject('signals', 'store')(
117-
DragDropContext(HTML5Backend)(observer(Routes))
111+
DragDropContext(HTML5Backend)(withRouter(observer(Routes)))
118112
);

packages/app/src/app/store/providers/FSSync.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,22 @@ async function syncDependencyTypings(
7676
Object.keys(absoluteDependencies).map(async depName => {
7777
const depVersion = absoluteDependencies[depName];
7878

79-
return fetch(`${SERVICE_URL}/${depName}@${depVersion}.json`)
80-
.then(x => x.json())
81-
.then(x => x.files)
82-
.then(x => {
83-
types = { ...types, ...x };
84-
85-
sendTypes();
86-
})
87-
.catch(() => {
79+
try {
80+
const fetchRequest = await fetch(`${SERVICE_URL}/${depName}@${depVersion}.json`);
81+
82+
if (!fetchRequest.ok) {
83+
throw new Error("Fetch error");
84+
}
85+
86+
const {files} = await fetchRequest.json();
87+
types = {...types, ...files};
88+
sendTypes();
89+
} catch (e) {
90+
if (process.env.NODE_ENV === 'development') {
8891
console.warn('Trouble fetching types for ' + depName);
89-
return {};
90-
});
92+
}
93+
return {};
94+
}
9195
})
9296
);
9397
} catch (e) {

standalone-packages/vscode-editor/release/min/vs/editor/codesandbox.editor.main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

standalone-packages/vscode-editor/release/min/vs/workbench/services/extensions/node/extensionHostProcess.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

standalone-packages/vscode-editor/release/min/vs/workbench/services/extensions/node/extensionHostProcess.nls.de.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)