mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00
async_hooks: make AsyncResource match emitInit
AsyncResource previously called emitInitNative. Since AsyncResource is just an abstraction on top of the emitEventScript functions, it should call emitInitScript instead. PR-URL: https://github.com/nodejs/node/pull/14152 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
628485ea01
commit
31417b6882
3 changed files with 18 additions and 21 deletions
29
test/parallel/test-async-hooks-asyncresource-constructor.js
Normal file
29
test/parallel/test-async-hooks-asyncresource-constructor.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
require('../common');
|
||||
|
||||
// This tests that AsyncResource throws an error if bad parameters are passed
|
||||
|
||||
const assert = require('assert');
|
||||
const async_hooks = require('async_hooks');
|
||||
const { AsyncResource } = async_hooks;
|
||||
|
||||
// Setup init hook such parameters are validated
|
||||
async_hooks.createHook({
|
||||
init() {}
|
||||
}).enable();
|
||||
|
||||
assert.throws(() => {
|
||||
return new AsyncResource();
|
||||
}, /^TypeError: type must be a string with length > 0$/);
|
||||
|
||||
assert.throws(() => {
|
||||
new AsyncResource('');
|
||||
}, /^TypeError: type must be a string with length > 0$/);
|
||||
|
||||
assert.throws(() => {
|
||||
new AsyncResource('type', -4);
|
||||
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);
|
||||
|
||||
assert.throws(() => {
|
||||
new AsyncResource('type', Math.PI);
|
||||
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);
|
Loading…
Add table
Add a link
Reference in a new issue