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

Favicon plugin causes a crash if no link is included #64

Closed
gingershaped opened this issue Dec 18, 2023 · 7 comments
Closed

Favicon plugin causes a crash if no link is included #64

gingershaped opened this issue Dec 18, 2023 · 7 comments
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@gingershaped
Copy link

gingershaped commented Dec 18, 2023

Current behaviour

If the HTML file does not include a <link rel="icon"> tag and the FaviconBundlerPlugin is enabled, webpack crashes with the following traceback:

  throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise1 + ')');
        ^

Error: Tap function (tapPromise) did not return promise (returned undefined)
    at _next0 (eval at create (/home/ginger/vyxal.github.io/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:33:9)
    at eval (eval at create (/home/ginger/vyxal.github.io/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:52:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Expected behaviour

The plugin should probably throw an error explaining that the file lacks a link tag.

Reproduction Example

Create an HTML file without a <link rel="icon"> tag, enable the FaviconBundlerPlugin, and attempt to bundle it with the HtmlBundlerWebpackPlugin.

Environment

  • OS: Linux
  • version of Node.js: v18.13.0
  • version of Webpack: 5.89.0
  • version of the Plugin: 3.4.0
@webdiscus
Copy link
Owner

Hello @GingerIndustries,

thank you for the issue report.
I wil fix it.

@webdiscus webdiscus added bug Something isn't working enhancement New feature or request labels Dec 18, 2023
@webdiscus
Copy link
Owner

it is a really special use case <link rel="icon"> or it's an user error? Should be this tag ignored or should an exception occur?

@gingershaped
Copy link
Author

it is a really special use case <link rel="icon"> or it's an user error? Should be this tag ignored or should an exception occur?

I'm of the opinion that if the plugin is enabled but the page lacks a favicon it's an error, since why would they have the plugin if they didn't have a favicon to use it with?

@webdiscus webdiscus added this to the development milestone Dec 18, 2023
@webdiscus
Copy link
Owner

I'm of the opinion that if the plugin is enabled but the page lacks a favicon it's an error, since why would they have the plugin if they didn't have a favicon to use it with?

yes/no

  • if the favicon plugin is used but no favicon found, this is an user error, not plugin error. User self should check the generated result and see whether all is correct
  • if no favicon was detect, then the favicon plugin should do nothing, just ignore it, no throw an error, because it brake compilation process (the HTML w/o favicon is valid)
  • if in Webpack config are configured CSS, images loaders and no CSS or images was in entry detected, the Webpack throw no exception
  • if html-bundler-webpack-plugin is configured with entry as a path to html templates and the entry directory is empty, this is no error too, just will be nothing rendered

All use cases such as <link rel="icon"> or <link invalid-href="./favicon.png" rel="icon" /> or the link tag is missing are the same. The plugin doesn't analyse whether any <link> tag exists or not in HTML. The plugin detect and resolve only attributes (href, src, etc) by tags. If any resolvable attribute is missing, then plugin do nothing, HTML stay as is.

Also, I will resolve this case (Favicon file is not found) w/o an exception.

@webdiscus
Copy link
Owner

webdiscus commented Dec 18, 2023

But I can display a warning in the console without breaking compilation, for example:

Warning

Favicon file is not found!
If the FaviconsBundlerPlugin is used, at last one favicon source file should be defined in the template, e.g.:
<link rel="icon" href="path/to/source/favicon.png">

@webdiscus webdiscus modified the milestones: development, test, done Dec 18, 2023
@webdiscus
Copy link
Owner

@GingerIndustries

the crashing is fixed, in this case will be display a warning.
Please check the version 3.4.3.

@gingershaped
Copy link
Author

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants