diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index c1590cc957e230..28b0b209922cc2 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -279,6 +279,7 @@ void StreamReq::Done(int status, const char* error_str) { AsyncWrap* async_wrap = GetAsyncWrap(); Environment* env = async_wrap->env(); if (error_str != nullptr) { + v8::HandleScope handle_scope(env->isolate()); async_wrap->object()->Set(env->context(), env->error_string(), OneByteString(env->isolate(), error_str)) diff --git a/test/parallel/test-https-agent-unref-socket.js b/test/parallel/test-https-agent-unref-socket.js new file mode 100644 index 00000000000000..b2863a74d817d4 --- /dev/null +++ b/test/parallel/test-https-agent-unref-socket.js @@ -0,0 +1,13 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const https = require('https'); + +const request = https.get('https://example.com'); + +request.on('socket', (socket) => { + socket.unref(); +});