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

Commit

Permalink
quic: fixup broken test when quic unavailable
Browse files Browse the repository at this point in the history
PR-URL: #359
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
jasnell committed Mar 17, 2020
1 parent 8c66e50 commit 08796cc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
7 changes: 7 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,13 @@ TBD
TBD

<a id="ERR_QUIC_UNAVAILABLE"></a>
### `ERR_QUIC_UNAVAILABLE`

> Stabililty: 1 - Experimental
TBD

<a id="ERR_QUICCLIENTSESSION_FAILED"></a>
### `ERR_QUICCLIENTSESSION_FAILED`

Expand Down
1 change: 1 addition & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@ E('ERR_QUIC_ERROR', function(code, family) {
return `QUIC session closed with ${familyType} error code ${code}`;
}, Error);
E('ERR_QUIC_TLS13_REQUIRED', 'QUIC requires TLS version 1.3', Error);
E('ERR_QUIC_UNAVAILABLE', 'QUIC is unavailable', Error);
E('ERR_REQUIRE_ESM',
(filename, parentPath = null, packageJsonPath = null) => {
let msg = `Must use import to load ES Module: ${filename}`;
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/quic/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ const kSocketDestroyed = 4;
let diagnosticPacketLossWarned = false;
let warnedVerifyHostnameIdentity = false;

assert(process.versions.ngtcp2 !== undefined);

// Called by the C++ internals when the socket is closed.
// When this is called, the only thing left to do is destroy
// the QuicSocket instance.
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/quic/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const {
},
} = require('internal/errors');

const assert = require('internal/assert');
assert(process.versions.ngtcp2 !== undefined);

const {
isIP,
} = require('internal/net');
Expand Down
11 changes: 11 additions & 0 deletions lib/quic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
'use strict';

const {
codes: {
ERR_QUIC_UNAVAILABLE,
},
} = require('internal/errors');
const { assertCrypto } = require('internal/util');

assertCrypto();
if (process.versions.ngtcp2 === undefined)
throw new ERR_QUIC_UNAVAILABLE();

const {
createSocket
} = require('internal/quic/core');
Expand Down
13 changes: 5 additions & 8 deletions src/node_native_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,20 @@ void NativeModuleLoader::InitializeModuleCategories() {
"crypto",
"https",
"http2",
#if !defined(NODE_EXPERIMENTAL_QUIC)
"quic",
#endif
"tls",
"_tls_common",
"_tls_wrap",
"internal/http2/core",
"internal/http2/compat",
#if !defined(NODE_EXPERIMENTAL_QUIC)
"internal/quic/core",
"internal/quic/util",
#endif
"internal/policy/manifest",
"internal/process/policy",
"internal/streams/lazy_transform",
#endif // !HAVE_OPENSSL

#if !defined(NODE_EXPERIMENTAL_QUIC)
"quic",
"internal/quic/core",
"internal/quic/util",
#endif
"sys", // Deprecated.
"wasi", // Experimental.
"internal/test/binding",
Expand Down

0 comments on commit 08796cc

Please sign in to comment.