From 960252f6895eaa3719569caa74956088b0b7e0d9 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 8 Jul 2020 11:18:25 -0700 Subject: [PATCH 1/3] quic: use less specific error codes Stop the madness. Only you can prevent excessive error code proliferation. --- doc/api/errors.md | 131 +++------------ doc/api/quic.md | 2 +- lib/internal/errors.js | 50 +----- lib/internal/quic/core.js | 158 ++++++++++-------- lib/internal/quic/util.js | 18 +- test/parallel/test-quic-client-server.js | 14 +- ...test-quic-errors-quicsession-openstream.js | 2 +- .../test-quic-errors-quicsocket-connect.js | 2 +- .../test-quic-errors-quicsocket-listen.js | 4 +- test/parallel/test-quic-ipv6only.js | 2 +- ...t-quic-quicsession-server-destroy-early.js | 5 +- test/parallel/test-quic-quicsocket-close.js | 3 +- test/parallel/test-quic-quicsocket.js | 7 +- 13 files changed, 138 insertions(+), 260 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 92715e1236bb96..d7254956feebe4 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1440,6 +1440,16 @@ type for one of its returned object properties on execution. Thrown in case a function option does not return an expected value type on execution, such as when a function is expected to return a promise. + +### `ERR_INVALID_STATE` + + +Indicates that an operation cannot be completed due to an invalid state. +For instance, an object may have already been destroyed, or may be +performing another operation. + ### `ERR_INVALID_SYNC_FORK_INPUT` @@ -1732,62 +1742,6 @@ Accessing `Object.prototype.__proto__` has been forbidden using [`Object.setPrototypeOf`][] should be used to get and set the prototype of an object. - -### `ERR_QUIC_CANNOT_SET_GROUPS` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUIC_ERROR` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUIC_TLS13_REQUIRED` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICCLIENTSESSION_FAILED` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICCLIENTSESSION_FAILED_SETSOCKET` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSESSION_DESTROYED` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSESSION_INVALID_DCID` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSESSION_UPDATEKEY` - -> Stability: 1 - Experimental - -TBD - ### `ERR_QUICSESSION_VERSION_NEGOTIATION` @@ -1795,62 +1749,6 @@ TBD TBD - -### `ERR_QUICSOCKET_DESTROYED` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSOCKET_INVALID_STATELESS_RESET_SECRET_LENGTH` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSOCKET_LISTENING` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSOCKET_UNBOUND` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSTREAM_DESTROYED` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSTREAM_INVALID_PUSH` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSTREAM_OPEN_FAILED` - -> Stability: 1 - Experimental - -TBD - - -### `ERR_QUICSTREAM_UNSUPPORTED_PUSH` - -> Stability: 1 - Experimental - -TBD - ### `ERR_REQUIRE_ESM` @@ -2482,6 +2380,15 @@ Used by the `N-API` when `Constructor.prototype` is not an object. A Node.js API was called in an unsupported manner, such as `Buffer.write(string, encoding, offset[, length])`. + +### `ERR_OPERATION_FAILED` + + +An operation failed. This is typically used to signal the general failure +of an asynchronous operation. + ### `ERR_OUTOFMEMORY` -* Type: {bigint} +* Type: {number} -A `BigInt` representing the number of retransmissions caused by delayed -acknowledgements. +The number of retransmissions caused by delayed acknowledgements. #### quicsession.address -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of bidirectional streams -created for this `QuicSession`. +The total number of bidirectional streams created for this `QuicSession`. #### quicsession.blockCount -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of times the `QuicSession` has -been blocked from sending stream data due to flow control. +The total number of times the `QuicSession` has been blocked from sending +stream data due to flow control. Such blocks indicate that transmitted stream data is not being consumed quickly enough by the connected peer. @@ -749,18 +747,18 @@ to the connected peer. added: REPLACEME --> -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of bytes received from the peer. +The total number of bytes received from the peer. #### quicsession.bytesSent -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of bytes sent to the peer. +The total number of bytes sent to the peer. #### quicsession.cipher -* Type: {bigint} +* Type: {number} -A `BigInt` representing the length of time the `QuicSession` was active. +The length of time the `QuicSession` was active. #### quicsession.getCertificate() -* Type: {bigint} +* Type: {number} -A `BigInt` representing the length of time taken to complete the TLS handshake. +The length of time taken to complete the TLS handshake. #### quicsession.idleTimeout -* Type: {bigint} +* Type: {number} -A `BigInt` representing the number of key update operations that have -occured. +The number of key update operations that have occured. #### quicsession.latestRTT -* Type: {bigint} +* Type: {number} The most recently recorded RTT for this `QuicSession`. @@ -939,10 +936,10 @@ The most recently recorded RTT for this `QuicSession`. added: REPLACEME --> -* Type: {bigint} +* Type: {number} -A `BigInt` representing the number of lost-packet retransmissions that have been -performed on this `QuicSession`. +The number of lost-packet retransmissions that have been performed on +this `QuicSession`. #### quicsession.maxDataLeft -* Type: {bigint} +* Type: {number} -A `BigInt` representing the maximum number of in-flight bytes recorded -for this `QuicSession`. +The maximum number of in-flight bytes recorded for this `QuicSession`. #### quicsession.maxStreams -* Type: {bigint} +* Type: {number} The minimum RTT recorded so far for this `QuicSession`. @@ -1025,10 +1021,9 @@ of the `ping()` operation. added: REPLACEME --> -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of `QuicStreams` initiated by the -connected peer. +The total number of `QuicStreams` initiated by the connected peer. #### quicsession.qlog -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of `QuicStream` instances initiated -by this `QuicSession`. +The total number of `QuicStream` instances initiated by this `QuicSession`. #### quicsession.servername -* Type: {bigint} +* Type: {number} The modified RTT calculated for this `QuicSession`. @@ -1107,10 +1101,9 @@ True if the `QuicSession` was closed due to QUIC stateless reset. added: REPLACEME --> -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of unidirectional streams -created on this `QuicSession`. +The total number of unidirectional streams created on this `QuicSession`. #### quicsession.updateKey() -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of bytes received for this -`QuicStream`. +The total number of bytes received for this `QuicStream`. #### quicstream.bytesSent -* Type: {bigint} +* Type: {number} -A `BigInt` representing the total number of bytes sent by this -`QuicStream`. +The total number of bytes sent by this `QuicStream`. #### quicstream.clientInitiated -* Type: {bigint} +* Type: {number} -A `BigInt` representing the length of time the `QuicStream` has been active. +The length of time the `QuicStream` has been active. #### quicstream.finalSize -* Type: {bigint} +* Type: {number} -A `BigInt` specifying the total number of bytes successfully received by the -`QuicStream`. +The total number of bytes successfully received by the `QuicStream`. #### quicstream.id -* Type: {bigint} +* Type: {number} -A `BigInt` representing the highest acknowledged data offset received -for this `QuicStream`. +The highest acknowledged data offset received for this `QuicStream`. #### quicstream.maxExtendedOffset -* Type: {bigint} +* Type: {number} -A `BigInt` representing the maximum extended data offset that has been -reported to the connected peer. +The maximum extended data offset that has been reported to the connected peer. #### quicstream.maxReceivedOffset -* Type: {bigint} +* Type: {number} -A `BigInt` representing the maximum received offset for this `QuicStream`. +The maximum received offset for this `QuicStream`. #### quicstream.pending