error during serialize.load

114 views
Skip to first unread message

Koen Van Wijk

unread,
Jan 5, 2022, 5:44:41 PM1/5/22
to Blockly
Hello,

With blockly VERSION: '7.20211209.1' I get the below error. If I read carefully you can see that the serialize load tries to create a block. The error happens on the highlighted line. 

Does someone recoqnize this issue?

Regards,
Koen 

Blockly.Blocks['model'] = {
  init: function() {
    this.appendDummyInput()
        .appendField(new Blockly.FieldLabelSerializable("Model", null, ), "MODEL_LABEL")
        .appendField(new Blockly.FieldNumber(7, -Infinity, Infinity, 1, null, ), "X")
        .appendField(new Blockly.FieldNumber(7, -Infinity, Infinity, 1, null, ), "Y")
        .appendField(new Blockly.FieldNumber(7, -Infinity, Infinity, 1, null, ), "Z");
    this.appendStatementInput("PROPERTIES")
   
    .setCheck(null);
    this.setNextStatement(true, null);
    this.setColour(65);
 this.setTooltip("");
 this.setHelpUrl("");
  },

 

blockly_compressed.js:997
Uncaught TypeError: Cannot read properties of null (reading '3') at new RenderedConnection (blockly_compressed.js:997) at BlockSvg.module$exports$Blockly$BlockSvg.BlockSvg.makeConnection_ (blockly_compressed.js:1083) at BlockSvg.module$exports$Blockly$Block.Block.appendInput_ (blockly_compressed.js:986) at BlockSvg.module$exports$Blockly$BlockSvg.BlockSvg.appendInput_ (blockly_compressed.js:1079) at BlockSvg.module$exports$Blockly$Block.Block.appendStatementInput (blockly_compressed.js:974) at BlockSvg.init (eval at myFactoryGeneration (block_factory_workspace.js:1), <anonymous>:2888:10) at BlockSvg.Block (blockly_compressed.js:935) at new BlockSvg (blockly_compressed.js:1034) at WorkspaceSvg.module$exports$Blockly$WorkspaceSvg.WorkspaceSvg.newBlock (blockly_compressed.js:1161) at module$contents$Blockly$serialization$blocks_appendPrivate (blockly_compressed.js:343)


RenderedConnection
@
blockly_compressed.js:997

module$exports$Blockly$BlockSvg.BlockSvg.makeConnection_
@
blockly_compressed.js:1083

module$exports$Blockly$Block.Block.appendInput_
@
blockly_compressed.js:986

module$exports$Blockly$BlockSvg.BlockSvg.appendInput_
@
blockly_compressed.js:1079

module$exports$Blockly$Block.Block.appendStatementInput
@
blockly_compressed.js:974

init
@
VM102268:2888

Block
@
blockly_compressed.js:935

BlockSvg
@
blockly_compressed.js:1034

module$exports$Blockly$WorkspaceSvg.WorkspaceSvg.newBlock
@
blockly_compressed.js:1161

module$contents$Blockly$serialization$blocks_appendPrivate
@
blockly_compressed.js:343

module$exports$Blockly$serialization$blocks.appendInternal
@
blockly_compressed.js:342

module$exports$Blockly$serialization$blocks.append
@
blockly_compressed.js:340

module$contents$Blockly$serialization$blocks_BlockSerializer.load
@
blockly_compressed.js:352

load
@
blockly_compressed.js:1645

xhr.onload
@
block_factory_workspace.js:760

Beka Westberg

unread,
Jan 6, 2022, 8:21:32 AM1/6/22
to blo...@googlegroups.com
Hello,

To me this looks like a Blockly bug, not a bug on your side. Seems like there's a problem with how OPPOSITE_TYPE is being exported (guessing the error is being triggered by the read here).

Could you create a minimal example/reproduction steps and post a bug in the core repo?

Thank you for finding this! Best wishes,
--Beka

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/606ae113-e920-47a8-b94f-f3b930abdf9bn%40googlegroups.com.

Koen Van Wijk

unread,
Jan 6, 2022, 5:19:32 PM1/6/22
to Blockly
Thanks for confirming that this is a Blockly bug. Do you have a workaround? Can I patch blockly? Or should like go back to xml :-(

My example is quite big. Could you describe a little more what seems to be the trigger?

Regards,
Koen

Beka Westberg

unread,
Jan 6, 2022, 7:29:33 PM1/6/22
to Blockly
So I got a PM from Mark saying that it might be caused by passing a non-svg workspace to load() instead of an svg one, so the connectionDBList is never initialized. But I'm not sure that that's what's happening here. From the stack trace it seems like you are actually working with a WorkspaceSvg. Plus the deserializer calls newBlock, so if it's a normal workspace you should get a non-rendered block, and therefore no rendered connection error.

So I'm not sure what the issue is. I thought OPPOSITE_TYPE might have been being exported incorrectly, so somehow it was null when the rendered connection tried to read it. However that seems pretty unlikely as well :/

Does this only trigger when loading from JSON? Or does it happen other times the block is created as well?

Before you load the blocks in, could you check whether `workspace.connectionDBList` or `internalConstants.OPPOSITE_TYPE` is null? That would really help with debugging.

Best,
--Beka

Koen Van Wijk

unread,
Jan 10, 2022, 5:36:53 PM1/10/22
to Blockly
Hello Beka,

Yes indeed my Blockly.internalConstants is null... maybe something to do with webpack...??

Regards,
Koen

Mark Friedman

unread,
Jan 10, 2022, 6:38:56 PM1/10/22
to blo...@googlegroups.com
Koen,

  It could have to do with Webpack.  How are you doing your Blockly import? 

-Mark


Koen Van Wijk

unread,
Jan 11, 2022, 3:49:50 AM1/11/22
to Blockly
Hello Mark,

import * as Blockly from 'blockly';

Regards,
Koen

Mark Friedman

unread,
Jan 11, 2022, 10:59:44 AM1/11/22
to blo...@googlegroups.com
That's what I, and a lot of Blockly examples, use, so that's probably not the problem.  If you feel comfortable sharing a pointer to your repo, we could take a closer look.

-Mark

Reply all
Reply to author
Forward
0 new messages