Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit 928c50e

Browse files
committed
quic: fixup broken test when quic unavailable
PR-URL: #359 Reviewed-By: Anna Henningsen <[email protected]>
1 parent e7b25da commit 928c50e

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

doc/api/errors.md

+7
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,13 @@ TBD
16951695
16961696
TBD
16971697

1698+
<a id="ERR_QUIC_UNAVAILABLE"></a>
1699+
### `ERR_QUIC_UNAVAILABLE`
1700+
1701+
> Stabililty: 1 - Experimental
1702+
1703+
TBD
1704+
16981705
<a id="ERR_QUICCLIENTSESSION_FAILED"></a>
16991706
### `ERR_QUICCLIENTSESSION_FAILED`
17001707

lib/internal/errors.js

+1
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,7 @@ E('ERR_QUIC_ERROR', function(code, family) {
13081308
return `QUIC session closed with ${familyType} error code ${code}`;
13091309
}, Error);
13101310
E('ERR_QUIC_TLS13_REQUIRED', 'QUIC requires TLS version 1.3', Error);
1311+
E('ERR_QUIC_UNAVAILABLE', 'QUIC is unavailable', Error);
13111312
E('ERR_REQUIRE_ESM',
13121313
(filename, parentPath = null, packageJsonPath = null) => {
13131314
let msg = `Must use import to load ES Module: ${filename}`;

lib/internal/quic/core.js

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ const kSocketDestroyed = 4;
245245
let diagnosticPacketLossWarned = false;
246246
let warnedVerifyHostnameIdentity = false;
247247

248+
assert(process.versions.ngtcp2 !== undefined);
249+
248250
// Called by the C++ internals when the socket is closed.
249251
// When this is called, the only thing left to do is destroy
250252
// the QuicSocket instance.

lib/internal/quic/util.js

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const {
99
},
1010
} = require('internal/errors');
1111

12+
const assert = require('internal/assert');
13+
assert(process.versions.ngtcp2 !== undefined);
14+
1215
const {
1316
isIP,
1417
} = require('internal/net');

lib/quic.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
'use strict';
22

3+
const {
4+
codes: {
5+
ERR_QUIC_UNAVAILABLE,
6+
},
7+
} = require('internal/errors');
8+
const { assertCrypto } = require('internal/util');
9+
10+
assertCrypto();
11+
if (process.versions.ngtcp2 === undefined)
12+
throw new ERR_QUIC_UNAVAILABLE();
13+
314
const {
415
createSocket
516
} = require('internal/quic/core');

src/node_native_module.cc

+5-8
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,20 @@ void NativeModuleLoader::InitializeModuleCategories() {
8787
"crypto",
8888
"https",
8989
"http2",
90-
#if !defined(NODE_EXPERIMENTAL_QUIC)
91-
"quic",
92-
#endif
9390
"tls",
9491
"_tls_common",
9592
"_tls_wrap",
9693
"internal/http2/core",
9794
"internal/http2/compat",
98-
#if !defined(NODE_EXPERIMENTAL_QUIC)
99-
"internal/quic/core",
100-
"internal/quic/util",
101-
#endif
10295
"internal/policy/manifest",
10396
"internal/process/policy",
10497
"internal/streams/lazy_transform",
10598
#endif // !HAVE_OPENSSL
106-
99+
#if !defined(NODE_EXPERIMENTAL_QUIC)
100+
"quic",
101+
"internal/quic/core",
102+
"internal/quic/util",
103+
#endif
107104
"sys", // Deprecated.
108105
"wasi", // Experimental.
109106
"internal/test/binding",

0 commit comments

Comments
 (0)