Skip to content

Encore should fail with exit status code > 0 in case of unhandled promise rejection error #855

@ostrolucky

Description

@ostrolucky

Background: Google web fonts API changed its API and now one of the plugins fail.

// webpack.config.js
let Encore            = require('@symfony/webpack-encore');
let GoogleFontsPlugin = require("google-fonts-webpack-plugin");

Encore
    // the project directory where all compiled assets will be stored
    .setOutputPath('public/build/')

    // the public path used by the web server to access the previous directory
    .setPublicPath('/build')

    // will create public/build/app.js and public/build/app.scss
    .addEntry('app', './assets/js/app.js')

    .addPlugin(new GoogleFontsPlugin({
        fonts: [
            { family: "Open Sans", variants: ["400", "600"] }
        ],
        "path": "fonts/"
    }))
;

// export the final configuration
module.exports = Encore.getWebpackConfig();
$ /vagrant/backoffice-eh/node_modules/.bin/encore dev
Running webpack ...

(node:26399) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at getVariantCss (/vagrant/backoffice-eh/node_modules/google-fonts-webpack-plugin/src/GoogleWebfonts.js:23:25)
    at variants.forEach.variant (/vagrant/backoffice-eh/node_modules/google-fonts-webpack-plugin/src/GoogleWebfonts.js:70:16)
    at Array.forEach (<anonymous>)
    at font.info.then.info (/vagrant/backoffice-eh/node_modules/google-fonts-webpack-plugin/src/GoogleWebfonts.js:67:14)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:26399) 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:26399) [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.
Done in 3.08s.
08:51 $ echo $?
0

This results in seemingly successful, but broken build, because manifest.js file is missing.

Plugin issue has been reported at SirPole/google-fonts-plugin#31. However, I want to stress that I am not asking here to fix this particular issue with this plugin, I am requesting a process to fail with error exit status code in case of these errors, so that borked build is not deployed to production.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions