Socket
Socket
Sign inDemoInstall

avvio

Package Overview
Dependencies
Maintainers
10
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 8.3.0 to 8.3.2

test/plugin-timeout-await.test.js

11

boot.js

@@ -176,3 +176,12 @@ 'use strict'

const plugin = new Plugin(fastq(this, this._loadPluginNextTick, 1), pluginFn, opts, isAfter, this._opts.timeout)
let timeout = this._opts.timeout
if (!current.loaded && current.timeout > 0) {
const delta = Date.now() - current.startTime
// We need to decrease it by 3ms to make sure the internal timeout
// is triggered earlier than the parent
timeout = current.timeout - (delta + 3)
}
const plugin = new Plugin(fastq(this, this._loadPluginNextTick, 1), pluginFn, opts, isAfter, timeout)
this._trackPluginLoading(plugin)

@@ -179,0 +188,0 @@

19

lib/plugin.js

@@ -53,2 +53,4 @@ 'use strict'

this._promise = null
this.startTime = null
}

@@ -121,2 +123,3 @@

this.started = true
this.startTime = Date.now()
this.emit('start', this.server ? this.server.name : null, this.name, Date.now())

@@ -150,10 +153,12 @@

if (afterErr) {
debug('rejecting promise', this.name, afterErr)
this._promise.reject(afterErr)
} else {
debug('resolving promise', this.name)
this._promise.resolve()
if (this._promise) {
if (afterErr) {
debug('rejecting promise', this.name, afterErr)
this._promise.reject(afterErr)
} else {
debug('resolving promise', this.name)
this._promise.resolve()
}
this._promise = null
}
this._promise = null

@@ -160,0 +165,0 @@ process.nextTick(callback, afterErr)

{
"name": "avvio",
"version": "8.3.0",
"version": "8.3.2",
"description": "Asynchronous bootstrapping of Node applications",

@@ -50,6 +50,4 @@ "main": "boot.js",

"@fastify/error": "^3.3.0",
"archy": "^1.0.0",
"debug": "^4.0.0",
"fastq": "^1.17.1"
}
}

@@ -198,1 +198,22 @@ 'use strict'

})
test('nested timeout do not crash - await', (t) => {
t.plan(4)
const app = boot({}, {
timeout: 10 // 10 ms
})
app.use(one)
async function one (app, opts) {
await app.use(two)
}
function two (app, opts, next) {
// do not call next on purpose
}
app.ready((err) => {
t.ok(err)
t.equal(err.fn, two)
t.equal(err.message, message('two'))
t.equal(err.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
})
})

Sorry, the diff of this file is not supported yet

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