mirror of https://github.com/nuxt/nuxt.git
fix: gracefully handle unhandled promises
This prevents nuxt process exiting in dev mode on unhandled promises
This commit is contained in:
parent
4bf0a46cb0
commit
85825d190c
11
bin/nuxt
11
bin/nuxt
|
@ -1,5 +1,9 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// Node Source Map Support
|
||||||
|
// https://github.com/evanw/node-source-map-support
|
||||||
|
require('source-map-support').install()
|
||||||
|
|
||||||
const join = require('path').join
|
const join = require('path').join
|
||||||
|
|
||||||
const defaultCommand = 'dev'
|
const defaultCommand = 'dev'
|
||||||
|
@ -21,4 +25,11 @@ if (commands.has(cmd)) {
|
||||||
|
|
||||||
const bin = join(__dirname, 'nuxt-' + cmd)
|
const bin = join(__dirname, 'nuxt-' + cmd)
|
||||||
|
|
||||||
|
// Console error unhandled promises
|
||||||
|
process.on('unhandledRejection', function (err) {
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
console.error(err)
|
||||||
|
console.error('[nuxt] Unhandled promise rejection: ' + err)
|
||||||
|
})
|
||||||
|
|
||||||
require(bin)
|
require(bin)
|
||||||
|
|
|
@ -54,11 +54,6 @@ const nuxtConfigFile = resolve(rootDir, argv['config-file'])
|
||||||
const nuxtConfig = loadNuxtConfig()
|
const nuxtConfig = loadNuxtConfig()
|
||||||
_.defaultsDeep(nuxtConfig, { watchers: { chokidar: { ignoreInitial: true } } })
|
_.defaultsDeep(nuxtConfig, { watchers: { chokidar: { ignoreInitial: true } } })
|
||||||
|
|
||||||
// Fail if an error happened
|
|
||||||
process.on('unhandledRejection', function (err) {
|
|
||||||
throw err
|
|
||||||
})
|
|
||||||
|
|
||||||
// Start dev
|
// Start dev
|
||||||
let dev = startDev()
|
let dev = startDev()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue