diff options
Diffstat (limited to 'test/async-hooks')
-rw-r--r-- | test/async-hooks/test-httpparser.request.js | 17 | ||||
-rw-r--r-- | test/async-hooks/test-httpparser.response.js | 18 |
2 files changed, 23 insertions, 12 deletions
diff --git a/test/async-hooks/test-httpparser.request.js b/test/async-hooks/test-httpparser.request.js index c6e18be5a6..71fccc0a85 100644 --- a/test/async-hooks/test-httpparser.request.js +++ b/test/async-hooks/test-httpparser.request.js @@ -1,3 +1,4 @@ +// Flags: --expose-internals 'use strict'; const common = require('../common'); @@ -6,17 +7,21 @@ const tick = require('./tick'); const initHooks = require('./init-hooks'); const { checkInvocations } = require('./hook-checks'); -const binding = process.binding('http_parser'); -const HTTPParser = binding.HTTPParser; +const hooks = initHooks(); +hooks.enable(); + +// The hooks.enable() must come before require('internal/test/binding') +// because internal/test/binding schedules a process warning on nextTick. +// If this order is not preserved, the hooks check will fail because it +// will not be notified about the nextTick creation but will see the +// callback event. +const { internalBinding } = require('internal/test/binding'); +const { HTTPParser } = internalBinding('http_parser'); const REQUEST = HTTPParser.REQUEST; const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; -const hooks = initHooks(); - -hooks.enable(); - const request = Buffer.from( 'GET /hello HTTP/1.1\r\n\r\n' ); diff --git a/test/async-hooks/test-httpparser.response.js b/test/async-hooks/test-httpparser.response.js index d56e3e1fec..eea40b14d1 100644 --- a/test/async-hooks/test-httpparser.response.js +++ b/test/async-hooks/test-httpparser.response.js @@ -1,3 +1,4 @@ +// Flags: --expose-internals 'use strict'; const common = require('../common'); @@ -6,17 +7,22 @@ const tick = require('./tick'); const initHooks = require('./init-hooks'); const { checkInvocations } = require('./hook-checks'); -const binding = process.binding('http_parser'); -const HTTPParser = binding.HTTPParser; +const hooks = initHooks(); + +hooks.enable(); + +// The hooks.enable() must come before require('internal/test/binding') +// because internal/test/binding schedules a process warning on nextTick. +// If this order is not preserved, the hooks check will fail because it +// will not be notified about the nextTick creation but will see the +// callback event. +const { internalBinding } = require('internal/test/binding'); +const { HTTPParser } = internalBinding('http_parser'); const RESPONSE = HTTPParser.RESPONSE; const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; const kOnBody = HTTPParser.kOnBody | 0; -const hooks = initHooks(); - -hooks.enable(); - const request = Buffer.from( 'HTTP/1.1 200 OK\r\n' + 'Content-Type: text/plain\r\n' + |