Socket
Socket
Sign inDemoInstall

avvio

Package Overview
Dependencies
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avvio - npm Package Compare versions

Comparing version 5.8.0 to 5.8.1

14

boot.js

@@ -134,8 +134,3 @@ 'use strict'

this._doStart = null
const main = new Plugin(this, function root (s, opts, done) {
this._doStart = done
if (opts.autostart) {
this.start()
}
}.bind(this), opts, noop)
const main = new Plugin(this, root.bind(this), opts, noop, 0)

@@ -157,2 +152,9 @@ Plugin.loadPlugin.call(this, main, (err) => {

function root (s, opts, done) {
this._doStart = done
if (opts.autostart) {
this.start()
}
}
inherits(Boot, EE)

@@ -159,0 +161,0 @@

{
"name": "avvio",
"version": "5.8.0",
"version": "5.8.1",
"description": "Asynchronous bootstrapping of Node applications",

@@ -5,0 +5,0 @@ "main": "boot.js",

@@ -28,3 +28,3 @@ 'use strict'

function Plugin (parent, func, opts, isAfter) {
function Plugin (parent, func, opts, isAfter, timeout) {
this.func = func

@@ -35,2 +35,3 @@ this.opts = opts

this.parent = parent
this.timeout = timeout === undefined ? parent._timeout : timeout
this.name = getName(func)

@@ -71,3 +72,4 @@ this.isAfter = isAfter

if (this.parent._timeout > 0) {
if (this.timeout > 0) {
debug('setting up timeout', name, this.timeout)
timer = setTimeout(function () {

@@ -80,3 +82,3 @@ debug('timed out', name)

done(err)
}, this.parent._timeout)
}, this.timeout)
}

@@ -83,0 +85,0 @@

@@ -29,4 +29,4 @@ 'use strict'

})
app.use(one)
function one (app, opts) {
app.use(two)
function two (app, opts) {
return new Promise(function (resolve) {

@@ -38,4 +38,4 @@ // do not call resolve on purpose

t.ok(err)
t.strictEqual(err.fn, one)
t.strictEqual(err.message, 'ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: one')
t.strictEqual(err.fn, two)
t.strictEqual(err.message, 'ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: two')
t.strictEqual(err.code, 'ERR_AVVIO_PLUGIN_TIMEOUT')

@@ -64,3 +64,3 @@ })

app.use(function (app, opts, next) {
// do not call next on purpose
// do not call next on purpose - code as name
})

@@ -70,5 +70,44 @@

t.ok(err)
t.strictEqual(err.message, 'ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: function (app, opts, next) { -- // do not call next on purposeone')
t.strictEqual(err.message, 'ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: function (app, opts, next) { -- // do not call next on purpose - code as name')
t.strictEqual(err.code, 'ERR_AVVIO_PLUGIN_TIMEOUT')
})
})
test('does not keep going', (t) => {
t.plan(2)
const app = boot({}, {
timeout: 10 // 10 ms
})
app.use(function three (app, opts, next) {
next(new Error('kaboom'))
})
app.ready((err) => {
t.ok(err)
t.strictEqual(err.message, 'kaboom')
})
})
test('throw in override without autostart', (t) => {
t.plan(2)
const server = { my: 'server' }
const app = boot(server, {
timeout: 10,
autostart: false
})
app.override = function (s) {
throw new Error('kaboom')
}
app.use(function (s, opts, cb) {
t.fail('this is never reached')
})
setTimeout(function () {
app.ready((err) => {
t.ok(err)
t.strictEqual(err.message, 'kaboom')
})
}, 20)
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc