mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
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
|
||||
|
||||
// Node Source Map Support
|
||||
// https://github.com/evanw/node-source-map-support
|
||||
require('source-map-support').install()
|
||||
|
||||
const join = require('path').join
|
||||
|
||||
const defaultCommand = 'dev'
|
||||
@ -21,4 +25,11 @@ if (commands.has(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)
|
||||
|
@ -54,11 +54,6 @@ const nuxtConfigFile = resolve(rootDir, argv['config-file'])
|
||||
const nuxtConfig = loadNuxtConfig()
|
||||
_.defaultsDeep(nuxtConfig, { watchers: { chokidar: { ignoreInitial: true } } })
|
||||
|
||||
// Fail if an error happened
|
||||
process.on('unhandledRejection', function (err) {
|
||||
throw err
|
||||
})
|
||||
|
||||
// Start dev
|
||||
let dev = startDev()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user