Comparing version 8.3.0 to 8.3.2
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 @@ |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
180652
2
68
6158
- Removedarchy@^1.0.0
- Removeddebug@^4.0.0
- Removedarchy@1.0.0(transitive)
- Removeddebug@4.3.7(transitive)
- Removedms@2.1.3(transitive)