diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 40276d87234865..a20275b3131287 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -1,8 +1,9 @@ 'use strict'; +const { internalBinding } = require('internal/bootstrap/loaders'); const Stream = require('stream'); const Readable = Stream.Readable; -const binding = process.binding('http2'); +const binding = internalBinding('http2'); const constants = binding.constants; const { ERR_HTTP2_HEADERS_SENT, diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index e5c2bf99ec37b0..299949481350e1 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -10,6 +10,7 @@ const { assertCrypto(); +const { internalBinding } = require('internal/bootstrap/loaders'); const assert = require('assert'); const EventEmitter = require('events'); const fs = require('fs'); @@ -31,7 +32,6 @@ const { owner_symbol, }, } = require('internal/async_hooks'); -const { internalBinding } = require('internal/bootstrap/loaders'); const { codes: { ERR_HTTP2_ALTSVC_INVALID_ORIGIN, @@ -114,7 +114,7 @@ const { const { isArrayBufferView } = require('internal/util/types'); const { FileHandle } = process.binding('fs'); -const binding = process.binding('http2'); +const binding = internalBinding('http2'); const { ShutdownWrap } = process.binding('stream_wrap'); const { UV_EOF } = internalBinding('uv'); diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index bc93662a70239d..473806aa18e300 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -1,6 +1,7 @@ 'use strict'; -const binding = process.binding('http2'); +const { internalBinding } = require('internal/bootstrap/loaders'); +const binding = internalBinding('http2'); const { ERR_HTTP2_HEADER_SINGLE_VALUE, ERR_HTTP2_INVALID_CONNECTION_HEADERS, diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 2e850db8716a0d..37ede26aa78996 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -80,10 +80,11 @@ let sessionStats; let streamStats; function collectHttp2Stats(entry) { + const http2 = internalBinding('http2'); switch (entry.name) { case 'Http2Stream': if (streamStats === undefined) - streamStats = process.binding('http2').streamStats; + streamStats = http2.streamStats; entry.id = streamStats[IDX_STREAM_STATS_ID] >>> 0; entry.timeToFirstByte = @@ -99,7 +100,7 @@ function collectHttp2Stats(entry) { break; case 'Http2Session': if (sessionStats === undefined) - sessionStats = process.binding('http2').sessionStats; + sessionStats = http2.sessionStats; entry.type = sessionStats[IDX_SESSION_STATS_TYPE] >>> 0 === 0 ? 'server' : 'client'; entry.pingRTT = diff --git a/src/node_http2.cc b/src/node_http2.cc index 12b0156f4a2e70..6711dc65a82818 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -2999,4 +2999,4 @@ HTTP_STATUS_CODES(V) } // namespace http2 } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(http2, node::http2::Initialize) +NODE_MODULE_CONTEXT_AWARE_INTERNAL(http2, node::http2::Initialize) diff --git a/test/parallel/test-http2-binding.js b/test/parallel/test-http2-binding.js index f267e2e6c1481e..ae19149d1bc74d 100644 --- a/test/parallel/test-http2-binding.js +++ b/test/parallel/test-http2-binding.js @@ -1,11 +1,13 @@ +// Flags: --expose-internals 'use strict'; const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); const assert = require('assert'); +const { internalBinding } = require('internal/test/binding'); -const binding = process.binding('http2'); +const binding = internalBinding('http2'); const http2 = require('http2'); assert(binding.Http2Session); diff --git a/test/parallel/test-http2-client-onconnect-errors.js b/test/parallel/test-http2-client-onconnect-errors.js index a75dc590c669a1..e72b5f454ba650 100644 --- a/test/parallel/test-http2-client-onconnect-errors.js +++ b/test/parallel/test-http2-client-onconnect-errors.js @@ -5,11 +5,12 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +const { internalBinding } = require('internal/test/binding'); const { constants, Http2Session, nghttp2ErrorString -} = process.binding('http2'); +} = internalBinding('http2'); const http2 = require('http2'); const { NghttpError } = require('internal/http2/util'); diff --git a/test/parallel/test-http2-info-headers-errors.js b/test/parallel/test-http2-info-headers-errors.js index 437add098b8a9f..e2cae58466bb82 100644 --- a/test/parallel/test-http2-info-headers-errors.js +++ b/test/parallel/test-http2-info-headers-errors.js @@ -5,11 +5,12 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); const http2 = require('http2'); +const { internalBinding } = require('internal/test/binding'); const { constants, Http2Stream, nghttp2ErrorString -} = process.binding('http2'); +} = internalBinding('http2'); const { NghttpError } = require('internal/http2/util'); // tests error handling within additionalHeaders diff --git a/test/parallel/test-http2-respond-errors.js b/test/parallel/test-http2-respond-errors.js index fa8a98b83f15ad..98f2558253deff 100644 --- a/test/parallel/test-http2-respond-errors.js +++ b/test/parallel/test-http2-respond-errors.js @@ -5,7 +5,8 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); const http2 = require('http2'); -const { Http2Stream } = process.binding('http2'); +const { internalBinding } = require('internal/test/binding'); +const { Http2Stream } = internalBinding('http2'); const server = http2.createServer(); diff --git a/test/parallel/test-http2-respond-nghttperrors.js b/test/parallel/test-http2-respond-nghttperrors.js index ad9eee0d59fecc..5ebd24a65b1b2f 100644 --- a/test/parallel/test-http2-respond-nghttperrors.js +++ b/test/parallel/test-http2-respond-nghttperrors.js @@ -5,11 +5,12 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); const http2 = require('http2'); +const { internalBinding } = require('internal/test/binding'); const { constants, Http2Stream, nghttp2ErrorString -} = process.binding('http2'); +} = internalBinding('http2'); const { NghttpError } = require('internal/http2/util'); // tests error handling within respond diff --git a/test/parallel/test-http2-respond-with-fd-errors.js b/test/parallel/test-http2-respond-with-fd-errors.js index 3a671a3e36490a..9dfd95ea5a2c7c 100644 --- a/test/parallel/test-http2-respond-with-fd-errors.js +++ b/test/parallel/test-http2-respond-with-fd-errors.js @@ -10,11 +10,12 @@ const fixtures = require('../common/fixtures'); const http2 = require('http2'); +const { internalBinding } = require('internal/test/binding'); const { constants, Http2Stream, nghttp2ErrorString -} = process.binding('http2'); +} = internalBinding('http2'); const { NghttpError } = require('internal/http2/util'); // tests error handling within processRespondWithFD diff --git a/test/parallel/test-http2-server-push-stream-errors.js b/test/parallel/test-http2-server-push-stream-errors.js index a6d2fe127827a8..e489cae439205e 100644 --- a/test/parallel/test-http2-server-push-stream-errors.js +++ b/test/parallel/test-http2-server-push-stream-errors.js @@ -5,11 +5,12 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); const http2 = require('http2'); +const { internalBinding } = require('internal/test/binding'); const { constants, Http2Stream, nghttp2ErrorString -} = process.binding('http2'); +} = internalBinding('http2'); const { NghttpError } = require('internal/http2/util'); // tests error handling within pushStream diff --git a/test/parallel/test-http2-util-headers-list.js b/test/parallel/test-http2-util-headers-list.js index 7b838835531977..2402e01cbf329e 100644 --- a/test/parallel/test-http2-util-headers-list.js +++ b/test/parallel/test-http2-util-headers-list.js @@ -9,7 +9,7 @@ if (!common.hasCrypto) common.skip('missing crypto'); const assert = require('assert'); const { mapToHeaders, toHeaderObject } = require('internal/http2/util'); - +const { internalBinding } = require('internal/test/binding'); const { HTTP2_HEADER_STATUS, HTTP2_HEADER_METHOD, @@ -88,7 +88,7 @@ const { HTTP2_HEADER_HOST, HTTP2_HEADER_KEEP_ALIVE, HTTP2_HEADER_PROXY_CONNECTION -} = process.binding('http2').constants; +} = internalBinding('http2').constants; { const headers = { diff --git a/test/parallel/test-http2-util-update-options-buffer.js b/test/parallel/test-http2-util-update-options-buffer.js index 6ab8bcff02866e..d9cfa0784926ae 100644 --- a/test/parallel/test-http2-util-update-options-buffer.js +++ b/test/parallel/test-http2-util-update-options-buffer.js @@ -9,7 +9,8 @@ if (!common.hasCrypto) // by the http2 implementation. const { updateOptionsBuffer } = require('internal/http2/util'); -const { optionsBuffer } = process.binding('http2'); +const { internalBinding } = require('internal/test/binding'); +const { optionsBuffer } = internalBinding('http2'); const { ok, strictEqual } = require('assert'); const IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE = 0;