mirror of https://github.com/lukechilds/node.git
Browse Source
This fixes the async_hooks.AsyncHook constructor such that it throws an error when provided with falsy values other than undefined. PR-URL: https://github.com/nodejs/node/pull/13096 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>v6
committed by
Andreas Madsen
2 changed files with 19 additions and 4 deletions
@ -0,0 +1,15 @@ |
|||||
|
'use strict'; |
||||
|
require('../common'); |
||||
|
|
||||
|
// This tests that using falsy values in createHook throws an error.
|
||||
|
|
||||
|
const assert = require('assert'); |
||||
|
const async_hooks = require('async_hooks'); |
||||
|
|
||||
|
for (const badArg of [0, 1, false, true, null, 'hello']) { |
||||
|
for (const field of ['init', 'before', 'after', 'destroy']) { |
||||
|
assert.throws(() => { |
||||
|
async_hooks.createHook({ [field]: badArg }); |
||||
|
}, new RegExp(`^TypeError: ${field} must be a function$`)); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue