fractal icon indicating copy to clipboard operation
fractal copied to clipboard

Async filter in view panel throws unreturned Promise warning

Open LeBenLeBen opened this issue 5 years ago • 10 comments

Using the latest version, I can see the following warning popping in the console when the server starts and when it reloads after file changes:

(node:85075) Warning: a promise was created in a handler but was not returned from it, see http://goo.gl/rRqMUw [0] Could not find the language 'text', did you forget to load/include a language module?

I’ve see this issue in two different projects.

I’ll try to investigate to see if I can find the origin of it.

LeBenLeBen avatar Apr 17 '20 10:04 LeBenLeBen

What's the version of installed highlight.js in your lockfile? I think you somehow got highlight.js v10 beta installed, which changes how "text" is parsed:

nohighlight or no-highlight are the only two CSS classes that will SKIP highlighting completely. text and plain no longer will do this.

mihkeleidast avatar Apr 21 '20 06:04 mihkeleidast

@risker I have currently the same warning

Could not find the language 'vue', did you forget to load/include a language module?

the current version in the lock file is the following (released on Feb 1)

    "highlight.js": {
      "version": "9.18.1",
      "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.1.tgz",
      "integrity": "sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg=="
    },

maximedaoust avatar Apr 21 '20 13:04 maximedaoust

@risker I've just checked and have 9.18.1 in both main repo and theme.

LeBenLeBen avatar Apr 22 '20 06:04 LeBenLeBen

@maximedaoust According to this list Highlight.js does not support vue out of the box. You probably need an extension like https://github.com/highlightjs/highlightjs-vue

LeBenLeBen avatar Apr 22 '20 06:04 LeBenLeBen

It's a bit weird to debug this since it's hard to reproduce without code :)

Are you by any chance using code blocks in docs files? E.g.

\```text
codeee
 \```

That should be incorrect, and should use plaintext instead.

Anyhow, that error reporting was introduced in highlight.js#2236 and released in v9.17. Before that it seems that lib did not complain about missing languages. So I'm guessing you need to update the languages in your projects.

Regarding the Promise warning, I don't think this is related to the highlight.js issue? In any case, a reproducible case would be appreciated.

mihkeleidast avatar Apr 22 '20 17:04 mihkeleidast

The warning appears in the console when I navigate to components page. It doesn't appear on docs page nor on components "preview" page. So my guess is that it's probably linked with the component panels (html, view, context, info or notes).

I started removing panels one after the other. After removing the "context" panel, the following warning disappeared:

(node:85075) Warning: a promise was created in a handler but was not returned from it, see http://goo.gl/rRqMUw

If the panel is present but the component doesn't have any context, no warning is thrown. I've overrided the template to see which line was causing the warning, it's this one (or this one if not a variant).

Removing the async filter seems to fix the issue without breaking the functionnality, at least in serve mode, but my knowledge about this is too limited to know if it could have other consequences.


After removing the "views" panel, the other warning disappeared:

[0] Could not find the language 'text', did you forget to load/include a language module?

The error is probably caused by this line where it fallback to the value of entity.lang which is text instead of using entity.editorMode which is undefined.

I could trace the issue back to this line and though the issue was caused by @allmarkedup/fang that doesn't support the nunj extension for Nunjucks files but only njk.

So I renamed all the my templates from nunj to njk but that didn't make it, I still get text as type. Fractal is still using @allmarkedup/fang version 1 which doesn't seem to mention Nunjucks whereas version 2 does. Maybe updating it will fix it?

Edit: I've just seen this MR https://github.com/frctl/fractal/pull/579/files 😅

LeBenLeBen avatar Apr 26 '20 09:04 LeBenLeBen

Hi @LeBenLeBen, without my PR, fang is still at version 1.0.0 which doesn't support the njk extension yet.

levito avatar Apr 26 '20 11:04 levito

@LeBenLeBen i can't test this theory out myself since i'm unable to reproduce the promise warning, but looking at our implementation of the async filter, it seems that we do not return the promises from the filter on lines 13 nor 15. Can you test if simply returning the promises there resolves the issue?

mihkeleidast avatar Apr 27 '20 18:04 mihkeleidast

Sorry, I forgot to mention the repository where this happens is public: https://github.com/liip/styleguide

I tried to add the returns but it didn't solve the issue.

I just saw that we actually have this in the config file:

/**
 * Prevent Bluebird warnings like "a promise was created in a handler but was not returned from it"
 * caused by Nunjucks from polluting the console
 */
const bluebird = require('bluebird');
bluebird.config({
  warnings: false,
});

I've quickly checked Bluebird and it still seems to be the right way. It's weird it doesn't apply to this specific case.

I think I must have found this in https://github.com/frctl/fractal/issues/235 at the time.

LeBenLeBen avatar Apr 29 '20 08:04 LeBenLeBen

The following warning:

[0] Could not find the language 'text', did you forget to load/include a language module?

Has been fixed by #579

LeBenLeBen avatar Apr 29 '20 08:04 LeBenLeBen