@@ -8,6 +8,7 @@ import VMScratchBlocks from '../lib/blocks';
88import VM from 'scratch-vm' ;
99
1010import analytics from '../lib/analytics' ;
11+ import log from '../lib/log.js' ;
1112import Prompt from './prompt.jsx' ;
1213import ConnectionModal from './connection-modal.jsx' ;
1314import BlocksComponent from '../components/blocks/blocks.jsx' ;
@@ -300,7 +301,21 @@ class Blocks extends React.Component {
300301 // Remove and reattach the workspace listener (but allow flyout events)
301302 this . workspace . removeChangeListener ( this . props . vm . blockListener ) ;
302303 const dom = this . ScratchBlocks . Xml . textToDom ( data . xml ) ;
303- this . ScratchBlocks . Xml . clearWorkspaceAndLoadFromXml ( dom , this . workspace ) ;
304+ try {
305+ this . ScratchBlocks . Xml . clearWorkspaceAndLoadFromXml ( dom , this . workspace ) ;
306+ } catch ( error ) {
307+ // The workspace is likely incomplete. What did update should be
308+ // functional.
309+ //
310+ // Instead of throwing the error, by logging it and continuing as
311+ // normal lets the other workspace update processes complete in the
312+ // gui and vm, which lets the vm run even if the workspace is
313+ // incomplete. Throwing the error would keep things like setting the
314+ // correct editing target from happening which can interfere with
315+ // some blocks and processes in the vm.
316+ error . message = `Workspace Update Error: ${ error . message } ` ;
317+ log . error ( error ) ;
318+ }
304319 this . workspace . addChangeListener ( this . props . vm . blockListener ) ;
305320
306321 if ( this . props . vm . editingTarget && this . state . workspaceMetrics [ this . props . vm . editingTarget . id ] ) {
0 commit comments