diff --git a/lib/internal/quic/core.js b/lib/internal/quic/core.js index 7e874ff34d58de..c6b3f5a5ea6b40 100644 --- a/lib/internal/quic/core.js +++ b/lib/internal/quic/core.js @@ -247,19 +247,11 @@ 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. -function onSocketClose() { - this[owner_symbol].destroy(); -} - -// Called by the C++ internals when an error occurs on the socket. -// When this is called, the only thing left to do is destroy -// the QuicSocket instance with an error. -// TODO(@jasnell): Should consolidate this with onSocketClose -function onSocketError(err) { - this[owner_symbol].destroy(errnoException(err)); +// Called by the C++ internals when the QuicSocket is closed with +// or without an error. The only thing left to do is destroy the +// QuicSocket instance. +function onSocketClose(err) { + this[owner_symbol].destroy(err != null ? errnoException(err) : undefined); } // Called by the C++ internals when the server busy state of @@ -579,7 +571,6 @@ function onStreamBlocked() { // Register the callbacks with the QUIC internal binding. setCallbacks({ onSocketClose, - onSocketError, onSocketServerBusy, onSessionReady, onSessionCert, diff --git a/src/quic/node_quic.cc b/src/quic/node_quic.cc index 202767a670a30b..2ddc1dd7fe9fa9 100644 --- a/src/quic/node_quic.cc +++ b/src/quic/node_quic.cc @@ -55,7 +55,6 @@ void QuicSetCallbacks(const FunctionCallbackInfo& args) { } while (0) SETFUNCTION("onSocketClose", socket_close); - SETFUNCTION("onSocketError", socket_error); SETFUNCTION("onSessionReady", session_ready); SETFUNCTION("onSessionCert", session_cert); SETFUNCTION("onSessionClientHello", session_client_hello); diff --git a/src/quic/node_quic_socket.cc b/src/quic/node_quic_socket.cc index ce7c5820b2d7b1..6c341d529c16f2 100644 --- a/src/quic/node_quic_socket.cc +++ b/src/quic/node_quic_socket.cc @@ -137,7 +137,7 @@ void JSQuicSocketListener::OnError(ssize_t code) { HandleScope scope(env->isolate()); Context::Scope context_scope(env->context()); Local arg = Number::New(env->isolate(), static_cast(code)); - socket()->MakeCallback(env->quic_on_socket_error_function(), 1, &arg); + socket()->MakeCallback(env->quic_on_socket_close_function(), 1, &arg); } void JSQuicSocketListener::OnSessionReady(BaseObjectPtr session) {