Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Message String... warning in console #4369

Closed
stclairdaniel opened this issue Oct 13, 2020 · 35 comments · Fixed by #7504
Closed

No Message String... warning in console #4369

stclairdaniel opened this issue Oct 13, 2020 · 35 comments · Fixed by #7504
Assignees
Labels
issue: bug Describes why the code or behaviour is wrong
Milestone

Comments

@stclairdaniel
Copy link

Describe the bug

In a minimal Blockly use case with a simple toolbox, warnings of the following type appear in the console:

No message string for %{BKY_MATH_ONLIST_TOOLTIP_STD_DEV} in %{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}
No message string for %{BKY_MATH_ONLIST_TOOLTIP_RANDOM} in %{BKY_MATH_ONLIST_TOOLTIP_RANDOM}
...

To Reproduce

  1. Visit this minimal reproduction example and view the console

Expected behavior

No warnings in the console

Screenshots

Screen Shot 2020-10-13 at 2 28 53 PM

Desktop (please complete the following information):

  • OS: MacOS Catalina 10.15.6
  • Browse: Chrome 85.0.4183.121 (Official Build) (64-bit)
  • Version: "blockly": "3.20200924.3",
@stclairdaniel stclairdaniel added issue: triage Issues awaiting triage by a Blockly team member issue: bug Describes why the code or behaviour is wrong labels Oct 13, 2020
@moniika
Copy link
Contributor

moniika commented Oct 13, 2020

I think this is the same issue that is happening in #4358. I will close that one in favor of easier repro steps described here.

Based on investigation on that issue already done by @oleggo, Blockly.utils.checkMessageReferences is run after page load and in some environments the Blockly.Msg table is not yet loaded.

Blockly.utils.checkMessageReferences(msgTemplate);

@oleggo
Copy link

oleggo commented Oct 13, 2020

@moniika it happens in the case when Blockly main module starts to load AFTER document.readyState is set to 'complete'. It causes Blockly.utils.checkMessageReferences to be called immediately without waiting for current tick to finish, because of this code:

fn(); // Page has already loaded. Call immediately.

One possible scenario is when Blockly is loaded under Webpack.

@moniika moniika added this to the 2020_q4_release milestone Oct 20, 2020
@moniika moniika removed the issue: triage Issues awaiting triage by a Blockly team member label Oct 20, 2020
@moniika moniika self-assigned this Nov 24, 2020
@moniika moniika removed their assignment Mar 18, 2021
@becnealon
Copy link

Has this issue been fixed? I am still able to recover this error. Is there a recommended solution?

Desktop (please complete the following information):
OS: MacOS Big Sur 11.2.3
Browse: Chrome 87.0.4280.141 (Official Build) (arm64)
Version: "unpkg" 6.20210701.0 as well as "github/blockly" 7.20211209.0

@johnnyoshika
Copy link

I'm also interested in this issue. It started to appear when I split my React app using code splitting. Here's the relevant discussion on Google Groups: https://groups.google.com/g/blockly/c/VQ1qjKMe3m4/m/Z-s_T2vrEQAJ

@dojo-coder
Copy link

I am also facing this issue. Does anyone know how to fix this?

@stnor
Copy link

stnor commented Feb 7, 2022

Also having the issue. I'm using lazy loading with:

const Blockly = await import('blockly/browser');

@johnnyoshika
Copy link

@stnor That seems consistent with the problem I'm having. Although these warnings are annoying, they haven't been a problem for my app so far.

@alexbk66
Copy link

alexbk66 commented Mar 28, 2022

It also causes "screenshader.js:80 Uncaught Error: Tooltip function must return a string"

I don't do anything special, just load html with a simple Blockly example. Getting lots of warnings.

[EDIT]

Just noticed, all warning I'm getting are about TOOLTIP. if it helps...

No message string for %{BKY_TEXT_APPEND_TOOLTIP} in %{BKY_TEXT_APPEND_TOOLTIP}
No message string for %{BKY_MATH_ARITHMETIC_TOOLTIP_ADD} in %{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}

@BeksOmega
Copy link
Collaborator

Hello all! Sadly I'm not sure that this is something the core team can fix on our end :/ The issue is that Blockly's translation files need to be loaded before Blockly is loaded, which (as far as I can tell) is related to how Blockly gets webpacked/rolledup along with the rest of an application.

If you run into this issue, the only thing I can recommend (at the moment) is digging into how your architecture handles loading, to make sure that message files get loaded before the rest of Blockly.

If anyone has information about how the core team could ensure this from our end, we would love more information =)

@johnnyoshika
Copy link

I'm using Create React App, which does the loading using its pre-configured webpack settings. Create React App is pretty popular, so I imagine this will be a common problem with Blockly. That said, these warnings haven't been a problem other than the annoying console messages, so it's something I'm willing to live with.

@alexbk66
Copy link

I'm using Create React App, which does the loading using its pre-configured webpack settings. Create React App is pretty popular, so I imagine this will be a common problem with Blockly. That said, these warnings haven't been a problem other than the annoying console messages, so it's something I'm willing to live with.

But if you hover the mouse over the blocks - when it tries to display the Tooltip - doesn't it fail because the messages are not loaded?

@johnnyoshika
Copy link

@alexbk66 Is this the tooltip you're referring to? Seems to work for me:

image

@maribethb
Copy link
Contributor

Hi everyone,

We submitted a fix for a related issue and I'm hoping it may have helped this, but since we don't use Angular or React ourselves it would be great to hear from you. Could you try this beta version 8.0.1-beta.0 and see if this issue is resolved? Thanks!

@DBurkeAoE
Copy link

Hello, I just recently started a project using Blockly in Angular and was running into this issue when using version 8.0.0 but updating to the version 8.0.1-beta.0 was able to fix the problem. However when updating to version 8.0.1 that just released the problem returned so I had to go back to the beta version. Was the fix intentionally removed in the stable release for 8.0.1 and if so can we expect it in a future stable release?

@maribethb
Copy link
Contributor

Thanks for confirming that the beta patch fixed the issue in Angular! We hadn't been able to confirm that before so that is great to hear.

Unfortunately the patch we applied to fix it for this case broke using setLocale for those using multiple translation files, so we didn't include that patch in the latest beta. We aim to have a complete fix (for both use cases) before our next main release and we can likely put out a patch fix for this issue when we have one. You can follow along at #6123 for more details. Thanks!

@reedspool
Copy link

reedspool commented Jun 4, 2022

I am having this issue as well without a build step. I did npm install blockly today and have version 8.0.2. I serve my application simply with npx serve. This is how I am loading Blockly at the end of my <body /> tag:

        <script type="text/javascript" src="./node_modules/blockly/blockly_compressed.js"></script>
        <script type="text/javascript" src="./node_modules/blockly/msg/en.js"></script>
        <script type="text/javascript" src="./node_modules/blockly/javascript_compressed.js"></script>
        <script type="text/javascript" src="./node_modules/blockly/blocks_compressed.js"></script>

Unfortunately I'm not able to find the beta branch or release package to test if that would fix it.

If I move msg/en.js above blockly_compressed.js then I get this error followed by the list of tooltip message warnings:

en.js:8 Uncaught TypeError: Cannot set properties of undefined (setting 'Msg')
    at en.js:8:22
    at en.js:10:2

@adrianfung
Copy link

I use version 8.0.2 too.
I removed the node_modules/blockly/msg and use the GitHub's msg,
and then changed the script src to ./node_modules/blockly/msg/js/en.js

@johnnyoshika
Copy link

@BeksOmega I tried blockly@8.0.4-beta.0 and it results in this compile error which prevents my React app from loading:

image

This error doesn't occur in blockly@8.0.3-beta.1 so I believe it's a regression.

I hope that's helpful.

@maribethb
Copy link
Contributor

maribethb commented Jun 18, 2022

Thanks Johnny. We have the latest fix at 8.0.4-beta.1 and it seems to be working in all the tests we've thought to run so far. would greatly appreciate you taking another look!

@johnnyoshika
Copy link

@maribethb I just tried 8.0.4-beta.1 and unfortunately I still get the string warnings:

image

My environment is described here: https://groups.google.com/g/blockly/c/VQ1qjKMe3m4/m/DmoPBv7RDgAJ

If it'll be helpful, I can create a simple React repo with code splitting to reproduce the warnings.

@Gauntlet173
Copy link

I'm having a similar problem, with warnings on load, and the main visible issue being that the block context menus will no longer display because Msg is undefined at contextmenu_items.js at 570.

I just tried it using 8.0.4-beta.1 and it did not resolve the problem.

image

@Gauntlet173
Copy link

I have reverted Blawx to github's v8.0.2 and created a local copy of the 8.0.4 version of the en.js file, and loaded it as suggested above by @adrianfung and @jasonpanelli. That seems to be working.

@Insood
Copy link

Insood commented Aug 2, 2022

Hey all, I've been using <script src="https://unpkg.com/blockly/blockly.min.js"></script> and it used to work until 8.0.4.

Downgrading to 8.0.3 fixes this for me: <script src="https://unpkg.com/blockly@8.0.3/blockly.min.js"></script>

I've tried specifying 8.0.4-beta.1, but the issue still persists in that version.

I recommend bundling a specific version in your app :)

@maribethb
Copy link
Contributor

@Insood can you provide more information? How did 8.0.4 break for you and how are you loading the message files?

In particular if you were using one of the workarounds listed here where you used an older version of the msg files with v8.0.3 then I think if you remove the workaround and use the version packaged in the release then everything should work... but if there's a test case we missed and 8.0.4 is broken for you we'd like to know asap. Thanks!

@Gauntlet173
Copy link

Just as follow up, #6329 seems to have solved the problem for me. If I remove the workaround, and clone from the "develop" branch of the repository, it seems to be resolved.

@maribethb
Copy link
Contributor

Thanks for confirming! I believe most of the recent comments on this thread were really about #6123 and have accordingly marked that issue as closed.

Unfortunately that issue looked similar in effect to this one, but I've confirmed the original issue reported here is still occurring, as it relates to React specifically or perhaps lazy loading in general, so I'm going to leave this one open. In particular with this issue you'll get warnings in the console but everything will actually work as expected.

If anyone else reading this experiences a similar issue but things don't work as expected (in other words, you get these console warnings AND blocks/toolboxes actually appear broken) please open a new issue as that would not be related to this one. Thank you!

@frck006
Copy link

frck006 commented Oct 23, 2022

Hi,
I use @sveltejs/kit, vite 3.1.8 and with Blockly V9.0.1, the problem is always here:
image

@DaveWelling
Copy link

This creates a lot of garbage in our unit tests logs.
I know this workaround is ugly, but If you get as desperate as I was to get rid of this you can load your Blockly dependency like so:

/* eslint-disable */
// ******************************************************************************
// See issue https://github.com/google/blockly/issues/4369
// Blockly will not allow you to avoid printing out a bunch of useless
// localization warnings for messages we don't use.
// This clogs up unit testing logs, etc.
// The versions for both log and warn are because they keep changing which ones they are
// using across builds.
const tempConsoleLog = console.log;
const tempConsoleWarn = console.warn;
let Blockly;
try {
    console.log = message => {
        if (message.startsWith('WARNING: No message string for %{')) return;
        else tempConsoleLog(message);
    };
    console.warn = message => {
        if (message.startsWith('No message string for %{')) return;
        else tempConsoleWarn(message);
    };
    Blockly = require('blockly');
} finally {
    console.log = tempConsoleLog;
    console.warn = tempConsoleWarn;
}
// ******************************************************************************
/* eslint-enable */

I found we only needed to do this once in our entry point.

@semiaddict
Copy link

@maribethb,

... as it relates to React specifically or perhaps lazy loading in general...

This seems to be a general issue with lazy loading, as I am experiencing the same thing when lazy loading Blockly in a Vue 3 app.

@doctorpangloss
Copy link

Can this be resolved for real? I appreciate the purpose of these messages for developers, but it doesn't make sense to have them for end users.

@maribethb maribethb added the issue: triage Issues awaiting triage by a Blockly team member label Jul 27, 2023
@stasberkov
Copy link

M.b. introduce a flag do not show such errors when compile for prod mode?

@maribethb maribethb removed the issue: triage Issues awaiting triage by a Blockly team member label Aug 16, 2023
@maribethb maribethb modified the milestones: Bug Bash Backlog, Upcoming Aug 16, 2023
@rachel-fenichel
Copy link
Collaborator

@cpcallen this now happens in the playground, after your recent change to bootstrapping/loading. Did you expect that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.