Skip to content

Commit 7c172b4

Browse files
Only do silent pass if surpress_callback_exceptions=True, otherwise throw error
Non-existent running components will now only silently passed if surpress_callback_exceptions=True. Otherwise, an error will be thrown. Note: even if an error is thrown, the callback execution is not stopped. Only the side-update of the running component is ignored.
1 parent caa4461 commit 7c172b4

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

dash/dash-renderer/src/actions/callbacks.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
} from '../types/callbacks';
3737
import {isMultiValued, stringifyId, isMultiOutputProp} from './dependencies';
3838
import {urlBase} from './utils';
39-
import {getCSRFHeader} from '.';
39+
import {getCSRFHeader, dispatchError} from '.';
4040
import {createAction, Action} from 'redux-actions';
4141
import {addHttpHeaders} from '../actions';
4242
import {notifyObservers, updateProps} from './index';
@@ -330,13 +330,27 @@ async function handleClientside(
330330
return result;
331331
}
332332

333-
function updateComponent(component_id: any, props: any) {
333+
function updateComponent(component_id: any, props: any, cb: ICallbackPayload) {
334334
return function (dispatch: any, getState: any) {
335-
const paths = getState().paths;
335+
const {paths, config} = getState();
336336
const componentPath = getPath(paths, component_id);
337-
if (typeof componentPath === 'undefined') {
338-
// Can't find the component that was defined in the running keyword,
339-
// Let's skip the component to prevent the dashboard from crashing.
337+
if (!componentPath) {
338+
if (!config.suppress_callback_exceptions) {
339+
dispatchError(dispatch)(
340+
'ID running component not found in layout',
341+
[
342+
'Component defined in running keyword not found in layout.',
343+
`Component id: "${stringifyId(component_id)}"`,
344+
'This ID was used in the callback(s) for Output(s):',
345+
`${cb.output}`,
346+
'You can suppress this exception by setting',
347+
'`suppress_callback_exceptions=True`.'
348+
]
349+
);
350+
}
351+
// We need to stop further processing because functions further on
352+
// can't operate on an 'undefined' object, and they will throw an
353+
// error.
340354
return;
341355
}
342356
dispatch(
@@ -386,7 +400,7 @@ function sideUpdate(outputs: SideUpdateOutput, cb: ICallbackPayload) {
386400
return acc;
387401
}, [] as any[])
388402
.forEach(([id, idProps]) => {
389-
dispatch(updateComponent(id, idProps));
403+
dispatch(updateComponent(id, idProps, cb));
390404
});
391405
};
392406
}

0 commit comments

Comments
 (0)