diff options
author | Darshan Sen <darshan.sen@postman.com> | 2021-10-12 13:02:03 +0300 |
---|---|---|
committer | Node.js GitHub Bot <github-bot@iojs.org> | 2021-10-20 18:32:54 +0300 |
commit | 516cdcd8aaf4c693711d3359bcd45e0dac568b0c (patch) | |
tree | ba934d2b49b752cd755fcdd819829e5c271a3c76 /src/stream_base-inl.h | |
parent | 7ed303bebadecb08ed1a9deb914469c51acadec3 (diff) |
src,stream: remove `*Check*()` calls from non-`Initialize()` functions
There is no need to crash the process if any of these checks fail.
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
PR-URL: https://github.com/nodejs/node/pull/40425
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/stream_base-inl.h')
-rw-r--r-- | src/stream_base-inl.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index 22e5518b589..ef86587c0bd 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -149,9 +149,11 @@ int StreamBase::Shutdown(v8::Local<v8::Object> req_wrap_obj) { const char* msg = Error(); if (msg != nullptr) { - req_wrap_obj->Set( - env->context(), - env->error_string(), OneByteString(env->isolate(), msg)).Check(); + if (req_wrap_obj->Set(env->context(), + env->error_string(), + OneByteString(env->isolate(), msg)).IsNothing()) { + return UV_EBUSY; + } ClearError(); } @@ -203,9 +205,11 @@ StreamWriteResult StreamBase::Write( const char* msg = Error(); if (msg != nullptr) { - req_wrap_obj->Set(env->context(), - env->error_string(), - OneByteString(env->isolate(), msg)).Check(); + if (req_wrap_obj->Set(env->context(), + env->error_string(), + OneByteString(env->isolate(), msg)).IsNothing()) { + return StreamWriteResult { false, UV_EBUSY, nullptr, 0, {} }; + } ClearError(); } @@ -279,10 +283,12 @@ void StreamReq::Done(int status, const char* error_str) { 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)) - .Check(); + if (async_wrap->object()->Set( + env->context(), + env->error_string(), + OneByteString(env->isolate(), error_str)).IsNothing()) { + return; + } } OnDone(status); |