Mystery console warning

62 views
Skip to first unread message

Andrew Bullen

unread,
Aug 31, 2024, 10:56:26 AM8/31/24
to Blockly
In Blockly 11, I use this code to bring in and register the old color field for use in a custom block library:

import * as Blockly from 'blockly';
import { registerFieldColour } from '@blockly/field-colour';

// Register the field type
registerFieldColour();

Outwardly, this seems to work, but I get a console warning stating:
svgBlocks.js?t=1725115386598:6 Unable to unregister [field_colour][field] from the registry.

I don't understand the meaning or significance of this warning.

Would anyone be able to explain it to me?

Christopher Allen

unread,
Sep 2, 2024, 10:02:14 AM9/2/24
to blo...@googlegroups.com
Hi Andrew,

Outwardly, this seems to work, but I get a console warning stating:
svgBlocks.js?t=1725115386598:6 Unable to unregister [field_colour][field] from the registry. 
 
I don't understand the meaning or significance of this warning.
 
Previously FieldColour was included in core Blockly.  Because the plugin was published before the built-in version was removed, it attempts to unregister any previously-registered version before registering the version provided by the plugin.  As noted in the comment this generates a warning if (as is now the case) the field is not present in the registry.

I've opened PR #2454  to remove this code now that it is no longer needed, but in any case this message is harmless and can be ignored.


Best wishes,

Christopher

ewpa...@gmail.com

unread,
Sep 6, 2024, 12:07:35 PM9/6/24
to Blockly
I'm curious what the theory was around making this a warning in the first place. When I think about CS principles, in particular about idempotency, removing an object o from a set S should result in a set S' that doesn't contain o. If S already didn't contain o, having S = S' shouldn't be an issue at all and the objective has been met. The fact that there has to be a warning that S doesn't contain o seems strange to me.

Cheers,
Evan

Reply all
Reply to author
Forward
0 new messages