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

Failed rendering under "vuepress build" produces exit code 0 #570

Closed
avishnyakov opened this issue Jun 11, 2018 · 2 comments · Fixed by #615
Closed

Failed rendering under "vuepress build" produces exit code 0 #570

avishnyakov opened this issue Jun 11, 2018 · 2 comments · Fixed by #615
Labels
type: enhancement Request to enhance an existing feature

Comments

@avishnyakov
Copy link

avishnyakov commented Jun 11, 2018

Bug report

Seems that any errors during the rendering phase still reports exit code 0. Output won't have pages generated but vuepress reports exit code 0. Hard to detect issues and fail early under automated buids.

Version

0.10.0

Steps to reproduce

Put wrong, non-existing links to sidebar section in config.js to fail the rendering phase:

module.exports = {
    themeConfig = {
        sidebar: [ 
                {
                    title: 'Fail',
                    collapsable: false,
                    children: [ 
                        '/',
                        '/11',
                        '/hey-i-dont-exist',
                        'this-will-fail'    
                  ]
              }
        ]
   }
}

Let' run this:

vurpress build 
echo "Exit code:: $?"

Output:

.....
Rendering static HTML...
Rendering page: /[vuepress] No matching page found for sidebar item "/11"
[vuepress] No matching page found for sidebar item "/11"
[vuepress] No matching page found for sidebar item "/11"
Error rendering /:
TypeError: Cannot read property 'match' of undefined
    at getHash (tmp/vuepress-app/usr/local/lib/node_modules/vuepress/lib/default-theme/util.js:13:21)
    at util_isActive (tmp/vuepress-app/usr/local/lib/node_modules/vuepress/lib/default-theme/util.js:47:19)
    at server-bundle.js:6894:14
    at Array.some (<anonymous>)
    at resolveOpenGroupIndex (tmp/vuepress-app/usr/local/lib/node_modules/vuepress/lib/default-theme/Sidebar.vue:64:47)
    at VueComponent.refreshIndex (tmp/vuepress-app/usr/local/lib/node_modules/vuepress/lib/default-theme/Sidebar.vue:44:20)
    at VueComponent.created (tmp/vuepress-app/usr/local/lib/node_modules/vuepress/lib/default-theme/Sidebar.vue:35:9)
    at callHook (/usr/local/lib/node_modules/vuepress/node_modules/vue/dist/vue.runtime.common.js:2919:21)
    at VueComponent.Vue._init (/usr/local/lib/node_modules/vuepress/node_modules/vue/dist/vue.runtime.common.js:4628:5)
    at new VueComponent (/usr/local/lib/node_modules/vuepress/node_modules/vue/dist/vue.runtime.common.js:4796:12)
    at createComponentInstanceForVnode (/usr/local/lib/node_modules/vuepress/node_modules/vue-server-renderer/build.js:7342:10)
    at renderComponentInner (/usr/local/lib/node_modules/vuepress/node_modules/vue-server-renderer/build.js:7516:40)
    at renderComponent (/usr/local/lib/node_modules/vuepress/node_modules/vue-server-renderer/build.js:7491:5)
    at RenderContext.renderNode (/usr/local/lib/node_modules/vuepress/node_modules/vue-server-renderer/build.js:7407:5)
    at RenderContext.next (/usr/local/lib/node_modules/vuepress/node_modules/vue-server-renderer/build.js:2428:14)
    at cachedWrite (/usr/local/lib/node_modules/vuepress/node_modules/vue-server-renderer/build.js:2287:9)
Exit code: 0

What is expected?

vuepress build returns correct exit code on success/failure so that further automation is possible.

What is actually happening?

vuepress build returns incorrect exit code on success/failure so that further automation is not possible.

Other relevant information

  • win/macoks/docker
  • v9.5.0 on win / v9.11.1 on docker node:9.11.1-alpine
  • that's server side rendering on vuepress build
  • global install
  • npm
@sebiniemann
Copy link

sebiniemann commented Jun 19, 2018

We also stumbled over this problem during a continuous deployment process. Seems to be the same as #598

If needed, I can create you a reproduction repo later on. However, the main issue is that errors in /lib/build.js within the build process, for example during

  // render pages
  logger.wait('Rendering static HTML...')
  for (const page of options.siteData.pages) {
    await renderPage(page)
  }

are catched in /bin/vuepress.js by

wrapCommand(build)(path.resolve(dir), { debug, outDir })

// [...]

function wrapCommand (fn) {
  return (...args) => {
    return fn(...args).catch(err => {
      console.error(chalk.red(err.stack))
    })
  }
}

which ultimately returns 0 as exit code.

Adding process.exit(1) after console.error(chalk.red(err.stack)) could resolve this.

However, wrapCommand is also used by program.command('dev .... And I am not sure if it needs to differentiate between dev and build to continue the process on errors when using dev, but exiting with status code 1 when using build.

Do we need to differentiate between these two commands, or is it sufficient to add process.exit(1) in any case?

@ulivz
Copy link
Member

ulivz commented Jun 26, 2018

#615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Request to enhance an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants