Skip to content

Commit

Permalink
fix: Add error boundary to servers.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTolmay committed Nov 8, 2023
1 parent f40c135 commit c3f2c4f
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 30 deletions.
3 changes: 2 additions & 1 deletion packages/client/src/block/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

import React, { useState } from 'react';

import { ErrorBoundary } from '@lowdefy/block-utils';

import CategorySwitch from './CategorySwitch.js';
import ErrorBoundary from '../ErrorBoundary.js';
import MountEvents from '../MountEvents.js';

const Block = ({ block, Blocks, context, lowdefy, parentLoading }) => {
Expand Down
4 changes: 1 addition & 3 deletions packages/client/src/createIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import React from 'react';
import classNames from 'classnames';
import { omit, type } from '@lowdefy/helpers';
import Icon from '@ant-design/icons';
import { blockDefaultProps, makeCssClass } from '@lowdefy/block-utils';

import ErrorBoundary from './ErrorBoundary.js';
import { blockDefaultProps, ErrorBoundary, makeCssClass } from '@lowdefy/block-utils';

const lowdefyProps = [
'actionLog',
Expand Down
1 change: 1 addition & 0 deletions packages/servers/server-community/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"dependencies": {
"@lowdefy/actions-core": "4.0.0-rc.12",
"@lowdefy/api": "4.0.0-rc.12",
"@lowdefy/block-utils": "4.0.0-rc.12",
"@lowdefy/blocks-antd": "4.0.0-rc.12",
"@lowdefy/blocks-basic": "4.0.0-rc.12",
"@lowdefy/blocks-loaders": "4.0.0-rc.12",
Expand Down
24 changes: 14 additions & 10 deletions packages/servers/server-community/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import React, { useRef } from 'react';
import dynamic from 'next/dynamic';

import { ErrorBoundary } from '@lowdefy/block-utils';

import Auth from '../lib/client/auth/Auth.js';

// Must be in _app due to next specifications.
Expand All @@ -26,16 +28,18 @@ import '../build/plugins/styles.less';
function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
const lowdefyRef = useRef({});
return (
<Auth session={session}>
{(auth) => (
<Component
auth={auth}
lowdefy={lowdefyRef.current}
rootConfig={rootConfig}
pageConfig={pageConfig}
/>
)}
</Auth>
<ErrorBoundary fullPage>
<Auth session={session}>
{(auth) => (
<Component
auth={auth}
lowdefy={lowdefyRef.current}
rootConfig={rootConfig}
pageConfig={pageConfig}
/>
)}
</Auth>
</ErrorBoundary>
);
}

Expand Down
1 change: 1 addition & 0 deletions packages/servers/server-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"dependencies": {
"@lowdefy/actions-core": "4.0.0-rc.12",
"@lowdefy/api": "4.0.0-rc.12",
"@lowdefy/block-utils": "4.0.0-rc.12",
"@lowdefy/blocks-antd": "4.0.0-rc.12",
"@lowdefy/blocks-basic": "4.0.0-rc.12",
"@lowdefy/blocks-color-selectors": "4.0.0-rc.12",
Expand Down
10 changes: 7 additions & 3 deletions packages/servers/server-dev/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import React, { Suspense, useRef } from 'react';
import dynamic from 'next/dynamic';

import { ErrorBoundary } from '@lowdefy/block-utils';

import Auth from '../lib/client/auth/Auth.js';

// Must be in _app due to next specifications.
Expand All @@ -25,9 +27,11 @@ import '../build/plugins/styles.less';
function App({ Component }) {
const lowdefyRef = useRef({});
return (
<Suspense fallback="">
<Auth>{(auth) => <Component auth={auth} lowdefy={lowdefyRef.current} />}</Auth>
</Suspense>
<ErrorBoundary fullPage>
<Suspense fallback="">
<Auth>{(auth) => <Component auth={auth} lowdefy={lowdefyRef.current} />}</Auth>
</Suspense>
</ErrorBoundary>
);
}

Expand Down
1 change: 1 addition & 0 deletions packages/servers/server-enterprise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"dependencies": {
"@lowdefy/actions-core": "4.0.0-rc.12",
"@lowdefy/api": "4.0.0-rc.12",
"@lowdefy/block-utils": "4.0.0-rc.12",
"@lowdefy/blocks-antd": "4.0.0-rc.12",
"@lowdefy/blocks-basic": "4.0.0-rc.12",
"@lowdefy/blocks-loaders": "4.0.0-rc.12",
Expand Down
30 changes: 17 additions & 13 deletions packages/servers/server-enterprise/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import React, { useRef } from 'react';
import dynamic from 'next/dynamic';

import { ErrorBoundary } from '@lowdefy/block-utils';

import Auth from '../lib/client/auth/Auth.js';
import createLogUsage from '../lib/client/createLogUsage.js';

Expand All @@ -21,19 +23,21 @@ function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
const usageDataRef = useRef({});
const lowdefyRef = useRef({ eventCallback: createLogUsage({ usageDataRef }) });
return (
<Auth session={session}>
{(auth) => {
usageDataRef.current.user = auth.session?.hashed_id;
return (
<Component
auth={auth}
lowdefy={lowdefyRef.current}
rootConfig={rootConfig}
pageConfig={pageConfig}
/>
);
}}
</Auth>
<ErrorBoundary fullPage>
<Auth session={session}>
{(auth) => {
usageDataRef.current.user = auth.session?.hashed_id;
return (
<Component
auth={auth}
lowdefy={lowdefyRef.current}
rootConfig={rootConfig}
pageConfig={pageConfig}
/>
);
}}
</Auth>
</ErrorBoundary>
);
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions packages/utils/block-utils/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
import blockDefaultProps from './blockDefaultProps.js';
import blockSchema from './blockSchema.js';
import HtmlComponent from './HtmlComponent.js';
import ErrorBoundary from './ErrorBoundary.js';
import makeCssClass from './makeCssClass.js';
import mediaToCssObject from './mediaToCssObject.js';
import renderHtml from './renderHtml.js';

export {
blockDefaultProps,
blockSchema,
ErrorBoundary,
HtmlComponent,
makeCssClass,
mediaToCssObject,
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c3f2c4f

Please sign in to comment.