svg-sprite / gulp-svg-sprite

SVG sprites & stacks galore — Gulp plugin wrapping around svg-sprite that reads in a bunch of SVG files, optimizes them and creates SVG sprites and CSS resources in various flavours
MIT License
648 stars 43 forks source link

Error: UnhandledPromiseRejectionWarning when using template #78

Closed kolnogorov closed 6 years ago

kolnogorov commented 6 years ago

Hello!

When i'm using template, i have the following error:

(node:10695) UnhandledPromiseRejectionWarning
(node:10695) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id:1)
(node:10695) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

If i remove the template including, everything works ok.

My gulpfile is:

    gulp.task('svgicons', function() {
        return gulp
            .src('svgsprites/*.svg')
            .pipe(svgSprite({
                shape: {
                    spacing: {
                        padding: 10
                    }
                },
                mode: {
                    css: {
                        dest: '../public/',
                        prefix: '.svgicon-',
                        sprite: 'images/svgsprite.svg',
                        dimensions: true,
                        bust: false,
                        layout: 'vertical',
                        render: {
                            scss: {
                                dest: '../styles/sprites.scss',
                                template: 'templates/_sprite-template.scss'
                            }
                        }
                    }
                }
            }))
            .pipe(gulp.dest('./'))
    });

All paths and filenames seem to be correct. Have no idea why the error happens. Thank you.

kolnogorov commented 6 years ago

Sorry, i got it, it was my problem; really sorry about that!

perke-fc commented 6 years ago

@kolnogorov mind to share what the solution was? Have a same issue...

longzheng commented 6 years ago

I'm also running into this UnhandledPromiseRejectionWarning error running the latest version of the package.

"gulp-svg-sprite": "^1.4.0",

node -v
v8.12.0

gulp -v
[13:22:28] CLI version 1.4.0
[13:22:28] Local version 3.9.1
ghost commented 6 years ago

Also running into this UnhandledPromiseRejectionWarning

"gulp-svg-sprite": "^1.4.0",

node -v v10.10.0

gulp -v [14:49:00] CLI version 2.0.1 [14:49:00] Local version 3.9.1

longzheng commented 6 years ago

I figured out the problem, it has to do with the new release of SVGO on npm which is a dependency of svg-sprite which gulp-svg-sprite is dependant on.

It seems the latest version of svgo causes svg-sprite to throw an exception with any SVG file (I think it's a compatibility issue similar to https://github.com/svg/svgo/issues/1030).

I was able to "fix" this by reverting gulp-svg-sprite to 1.3.7 (and clearing my node_modules folder).