Skip to content
New issue

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

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

Already on GitHub? # to your account

'Fatal error' when processing favicon #19

Closed
chris-thorn opened this issue Nov 19, 2015 · 8 comments
Closed

'Fatal error' when processing favicon #19

chris-thorn opened this issue Nov 19, 2015 · 8 comments
Labels

Comments

@chris-thorn
Copy link

I'm having trouble getting the Grunt task to work.

Gruntfile.js task:

realFavicon: {
  favicons: {
    src: '<%= config.media %>/images/processed/favicon/favicon.png',
    dest: '<%= config.dist %>',
    options: {
      iconsPath: '/',
      html: [''],
      design: {
        ios: {
          pictureAspect: 'noChange'
        },
        desktopBrowser: {},
        windows: {
          pictureAspect: 'noChange',
          backgroundColor: '#da532c',
          onConflict: 'override'
        },
        androidChrome: {
          pictureAspect: 'noChange',
          themeColor: '#ffffff',
          manifest: {
            name: 'example.com',
            display: 'browser',
            orientation: 'notSet',
            onConflict: 'override'
          }
        },
        safariPinnedTab: {
          pictureAspect: 'blackAndWhite',
          threshold: 73.4375,
          themeColor: '#5bbad5'
        }
      },
      settings: {
        compression: 1,
        scalingAlgorithm: 'Mitchell',
        errorOnImageTooSmall: false
      }
    }
  }
},

It's basically what's given in the readme, just with a couple of updated paths. I wanted to see what the standard code output before making too many changes.

Console output:

λ grunt realFavicon --verbose --stack
Initializing
Command-line options: --verbose, --stack

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, default

Running tasks: realFavicon

Loading "grunt-real-favicon" plugin

Registering "E:\web\example.com\node_modules\grunt-real-favicon\tasks" tasks.
Loading "real_favicon.js" tasks...OK
+ realFavicon, real_favicon

Running "realFavicon" task

Running "realFavicon:favicons" (realFavicon) task
Verifying property realFavicon.favicons exists in config...OK
Files: media/images/processed/favicon/favicon.png -> dist
Options: iconsPath="/", html=[""], design={"ios":{"pictureAspect":"noChange"},"desktopBrowser":{},"windows":{"pictureAspect":"noChange","backgroundColor":"#da532c","onConflict":"override"},"androidChrome":{"pictureAspect":"noChange","themeColor":"#ffffff","manifest":{"name":"example.com","display":"browser","orientation":"notSet","onConflict":"override"}},"safariPinnedTab":{"pictureAspect":"blackAndWhite","threshold":73.4375,"themeColor":"#5bbad5"}}, settings={"compression":1,"scalingAlgorithm":"Mitchell","errorOnImageTooSmall":false}
Options: iconsPath="/", html=[""], design={"ios":{"pictureAspect":"noChange"},"desktopBrowser":{},"windows":{"pictureAspect":"noChange","backgroundColor":"#da532c","onConflict":"override"},"androidChrome":{"pictureAspect":"noChange","themeColor":"#ffffff","manifest":{"name":"example.com","display":"browser","orientation":"notSet","onConflict":"override"}},"safariPinnedTab":{"pictureAspect":"blackAndWhite","threshold":73.4375,"themeColor":"#5bbad5"}}, settings={"compression":1,"scalingAlgorithm":"Mitchell","errorOnImageTooSmall":false}
Options: iconsPath="/", html=[""], design={"ios":{"pictureAspect":"noChange"},"desktopBrowser":{},"windows":{"pictureAspect":"noChange","backgroundColor":"#da532c","onConflict":"override"},"androidChrome":{"pictureAspect":"noChange","themeColor":"#ffffff","manifest":{"name":"example.com","display":"browser","orientation":"notSet","onConflict":"override"}},"safariPinnedTab":{"pictureAspect":"blackAndWhite","threshold":73.4375,"themeColor":"#5bbad5"}}, settings={"compression":1,"scalingAlgorithm":"Mitchell","errorOnImageTooSmall":false}
Options: iconsPath="/", html=[""], design={"ios":{"pictureAspect":"noChange"},"desktopBrowser":{},"windows":{"pictureAspect":"noChange","backgroundColor":"#da532c","onConflict":"override"},"androidChrome":{"pictureAspect":"noChange","themeColor":"#ffffff","manifest":{"name":"example.com","display":"browser","orientation":"notSet","onConflict":"override"}},"safariPinnedTab":{"pictureAspect":"blackAndWhite","threshold":73.4375,"themeColor":"#5bbad5"}}, settings={"compression":1,"scalingAlgorithm":"Mitchell","errorOnImageTooSmall":false}
Options: iconsPath="/", html=[""], design={"ios":{"pictureAspect":"noChange"},"desktopBrowser":{},"windows":{"pictureAspect":"noChange","backgroundColor":"#da532c","onConflict":"override"},"androidChrome":{"pictureAspect":"noChange","themeColor":"#ffffff","manifest":{"name":"example.com","display":"browser","orientation":"notSet","onConflict":"override"}},"safariPinnedTab":{"pictureAspect":"blackAndWhite","threshold":73.4375,"themeColor":"#5bbad5"}}, settings={"compression":1,"scalingAlgorithm":"Mitchell","errorOnImageTooSmall":false}
Options: iconsPath="/", html=[""], design={"ios":{"pictureAspect":"noChange"},"desktopBrowser":{},"windows":{"pictureAspect":"noChange","backgroundColor":"#da532c","onConflict":"override"},"androidChrome":{"pictureAspect":"noChange","themeColor":"#ffffff","manifest":{"name":"example.com","display":"browser","orientation":"notSet","onConflict":"override"}},"safariPinnedTab":{"pictureAspect":"blackAndWhite","threshold":73.4375,"themeColor":"#5bbad5"}}, settings={"compression":1,"scalingAlgorithm":"Mitchell","errorOnImageTooSmall":false}
Process
Fatal error: Cannot read property 'parent' of undefined
TypeError: Cannot read property 'parent' of undefined
    at Function.exports.update (E:\web\example.com\node_modules\grunt-real-favicon\node_modules\rfg-api\node_modules\metaparser\node_modules\cheerio\lib\parse.js:55:25)
    at module.exports (E:\web\example.com\node_modules\grunt-real-favicon\node_modules\rfg-api\node_modules\metaparser\node_modules\cheerio\lib\parse.js:17:11)
    at Function.exports.load (E:\web\example.com\node_modules\grunt-real-favicon\node_modules\rfg-api\node_modules\metaparser\node_modules\cheerio\lib\static.js:19:14)
    at decodeData (E:\web\example.com\node_modules\grunt-real-favicon\node_modules\rfg-api\node_modules\metaparser\index.js:27:33)
    at E:\web\example.com\node_modules\grunt-real-favicon\node_modules\rfg-api\node_modules\metaparser\index.js:37:17
    at fn (E:\web\example.com\node_modules\grunt-real-favicon\node_modules\async\lib\async.js:741:34)
    at E:\web\example.com\node_modules\grunt-real-favicon\node_modules\async\lib\async.js:1208:16
    at E:\web\example.com\node_modules\grunt-real-favicon\node_modules\async\lib\async.js:166:37
    at E:\web\example.com\node_modules\grunt-real-favicon\node_modules\async\lib\async.js:701:43
    at E:\web\example.com\node_modules\grunt-real-favicon\node_modules\async\lib\async.js:167:37


Execution Time (2015-11-19 14:25:41 UTC)
loading tasks               265ms  ████ 3%
loading grunt-real-favicon  473ms  ███████ 5%
realFavicon:favicons         9.5s  ████████████............██████ 93%

Do you have any idea what the issue might be?

Thanks very much.

Chris

@chris-thorn
Copy link
Author

I should add, I'm using grunt 0.4.5 and grunt-real-favicon 0.1.3 on Windows 10.

@phbernard
Copy link
Contributor

Hi, thank you for reporting and sorry for the late answer.

Apparently this is because your html array contains a empty entry (''). Definitely not normal, I need to fix this.

Note that html should contain at least one file name. Else, you have no way to get the favicon HTML markups (either by injecting the markups in you HTML pages or by storing them in a file to use them later), which makes the whole process quite useless.

@phbernard phbernard added the bug label Dec 1, 2015
@phbernard
Copy link
Contributor

Well I don't want to add a special case for empty file name. After all, this is not the only illegal file name.

In the next version of the plugin, you will get additional information by adding --debug, such as [D] File '' exists, inject markups in it. This doesn't really fix the issue but the message shows that there is a problem with the file name.

phbernard added a commit that referenced this issue Dec 1, 2015
@phbernard
Copy link
Contributor

Done in v0.1.4

@chris-thorn
Copy link
Author

Hi Philippe,

Thanks for your help - I feel like an idiot - I completely missed the empty filename array html!

I've just re-run it and it has now injected the favicon markup into the page.

One question though (and I might be missing something else here) - what determines the position on the page where the favicon markup gets injected?

Thanks again,

Chris

@phbernard
Copy link
Contributor

No prolem, I didn't spot it either, and I had to debug to find out!

The injection is done with the append method of Cheerio, so the markups should be placed at the end of the head.

@chris-thorn
Copy link
Author

OK cool, thanks very much :)

Chris

@phbernard
Copy link
Contributor

You're welcome!

Philippe

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants