blockly-samples icon indicating copy to clipboard operation
blockly-samples copied to clipboard

blockly-react demo broken by Blockly v9 due to multiple issues

Open cpcallen opened this issue 3 years ago • 2 comments

Category

  • Examples

Component

examples/blockly-react

Describe the bug

The demo fails to load due to multiple issues:

  1. Throws TypeError in examples/blockly-react/src/generator/generator.js due to use of Blockly.JavaScript. After fixing this, it also:
  2. Throws TypeErrors due to issue #1267
  3. Throws TypeError for unclear reasons (but possibly secondary effects of issue 2).

To Reproduce

Steps to reproduce the behavior:

  1. Go to examples/blockly-react.
  2. Run npm install [email protected] to link against current Blockly beta.
  3. Runnpm start to start the dev server.
  4. Observe error TypeError: Cannot set properties of undefined (setting 'test_react_field') (full stack trace below) shown in both page and browser console.
  5. Fix this by cherry-picking PR #1270.
  6. Click reload in browser.
  7. Open browser console to observe TypeError: Class constructors cannot be invoked without 'new' (x2 similar) and TypeError: Cannot read properties of null (reading 'length') (x2 identical).

Expected behaviour

No errors occur; demo loads successfully.

Stack traces

Issue 1:

TypeError: Cannot set properties of undefined (setting 'test_react_field')
    at 159 (generator.js:30:1)
    at u (index.html:1:1099)
    at t (index.html:1:968)
    at Array.r [as push] (index.html:1:831)
    at main.8f1198ce.chunk.js:2:89

Issue 2 (caused by bug #1267):

    at new Blockly.FieldDate (field_date.js:51:1)
    at Blockly.FieldDate.fromJson (field_date.js:71:1)
    at Object.fromJsonInternal$$module$build$src$core$field_registry [as fromJsonInternal] (blockly_compressed.js:176:1)
    at fromJson$$module$build$src$core$field_registry (blockly_compressed.js:175:1)
    at BlockSvg$$module$build$src$core$block_svg.fieldFromJson_ (blockly_compressed.js:659:1)
    at BlockSvg$$module$build$src$core$block_svg.interpolate_ (blockly_compressed.js:657:1)
    at BlockSvg$$module$build$src$core$block_svg.jsonInit (blockly_compressed.js:653:1)
    at BlockSvg$$module$build$src$core$block_svg.init (customblocks.js:52:1)
    at BlockSvg$$module$build$src$core$block_svg.doInit_ (blockly_compressed.js:630:1)
    at new BlockSvg$$module$build$src$core$block_svg (blockly_compressed.js:711:1)
    at WorkspaceSvg$$module$build$src$core$workspace_svg.newBlock (blockly_compressed.js:1471:1)
    at domToBlockHeadless$$module$build$src$core$xml (blockly_compressed.js:102:1)
    at domToBlock$$module$build$src$core$xml (blockly_compressed.js:94:1)
    at VerticalFlyout$$module$build$src$core$flyout_vertical.createFlyoutBlock_ (blockly_compressed.js:1323:1)
    at VerticalFlyout$$module$build$src$core$flyout_vertical.createFlyoutInfo_ (blockly_compressed.js:1321:1)
    at VerticalFlyout$$module$build$src$core$flyout_vertical.show (blockly_compressed.js:1319:1)
    at init$$module$build$src$core$inject (blockly_compressed.js:274:1)
    at Object.inject$$module$build$src$core$inject [as inject] (blockly_compressed.js:269:1)
    at BlocklyComponent.jsx:49:1
    at invokePassiveEffectCreate (react-dom.development.js:23487:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at flushPassiveEffectsImpl (react-dom.development.js:23574:1)
    at unstable_runWithPriority (scheduler.development.js:646:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at flushPassiveEffects (react-dom.development.js:23447:1)
    at react-dom.development.js:23324:1
    at workLoop (scheduler.development.js:590:1)
    at flushWork (scheduler.development.js:545:1)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:157:1)

Issue 3 (possibly secondary damage from issue 2):

Could not get the stack frames of error: TypeError: Cannot read properties of null (reading 'length')
    at F (index.js:1:1)
    at index.js:1:1
    at Array.map (<anonymous>)
    at index.js:1:1
    at s (index.js:1:1)
    at Generator._invoke (index.js:1:1)
    at Generator.next (index.js:1:1)
    at N (index.js:1:1)
    at i (index.js:1:1)

Additional context

cpcallen avatar Sep 12 '22 13:09 cpcallen

Ooops; pressed submit too early. Finishing report…

cpcallen avatar Sep 12 '22 13:09 cpcallen

@cpcallen did #1270 fix this?

rachel-fenichel avatar Oct 01 '22 00:10 rachel-fenichel

It seems so, demo appears to be working fine with 9.3.2.

gonfunko avatar Apr 14 '23 17:04 gonfunko

@cpcallen did #1270 fix this?

It is so long ago I no longer recall creating either the issue or the PR, but it certainly appears to be the case that I intended the latter to fix the former, and it appears to have suceeded.

cpcallen avatar Apr 21 '23 09:04 cpcallen