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

Async filter in view panel throws unreturned Promise warning #576

Open
LeBenLeBen opened this issue Apr 17, 2020 · 10 comments
Open

Async filter in view panel throws unreturned Promise warning #576

LeBenLeBen opened this issue Apr 17, 2020 · 10 comments

Comments

@LeBenLeBen
Copy link
Member

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.

@mihkeleidast
Copy link
Member

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.

@maximedaoust

This comment has been minimized.

@LeBenLeBen
Copy link
Member Author

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

@LeBenLeBen

This comment has been minimized.

@mihkeleidast
Copy link
Member

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.

@LeBenLeBen
Copy link
Member Author

LeBenLeBen commented Apr 26, 2020

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 😅

@levito
Copy link
Contributor

levito commented Apr 26, 2020

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

@mihkeleidast
Copy link
Member

@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?

@LeBenLeBen
Copy link
Member Author

LeBenLeBen commented Apr 29, 2020

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 #235 at the time.

@LeBenLeBen
Copy link
Member Author

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 LeBenLeBen changed the title Warnings in console caused by missing Highlight.js language Async filter in view panel throws unreturned Promise warning May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants