Skip to content

Commit be8fbda

Browse files
committed
src,stream: change return type to Maybe
This changes the return types of some functions to indicate that the functions may have a pending exception, and removes some of todos related. Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com
1 parent 3507b3f commit be8fbda

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/stream_wrap.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ static MaybeLocal<Object> AcceptHandle(Environment* env,
239239
return scope.Escape(wrap_obj);
240240
}
241241

242-
243-
void LibuvStreamWrap::OnUvRead(ssize_t nread, const uv_buf_t* buf) {
242+
v8::Maybe<void> LibuvStreamWrap::OnUvRead(ssize_t nread, const uv_buf_t* buf) {
244243
HandleScope scope(env()->isolate());
245244
Context::Scope context_scope(env()->context());
246245
uv_handle_type type = UV_UNKNOWN_HANDLE;
@@ -272,14 +271,14 @@ void LibuvStreamWrap::OnUvRead(ssize_t nread, const uv_buf_t* buf) {
272271
object()->Set(env()->context(),
273272
env()->pending_handle_string(),
274273
local_pending_obj).IsNothing()) {
275-
return;
274+
return v8::Nothing<void>();
276275
}
277276
}
278277

279278
EmitRead(nread, *buf);
279+
return v8::JustVoid();
280280
}
281281

282-
283282
void LibuvStreamWrap::GetWriteQueueSize(
284283
const FunctionCallbackInfo<Value>& info) {
285284
LibuvStreamWrap* wrap;

src/stream_wrap.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase {
105105

106106
// Callbacks for libuv
107107
void OnUvAlloc(size_t suggested_size, uv_buf_t* buf);
108-
// TODO(RaisinTen): Update the return type to a Maybe, so that we can indicate
109-
// if there is a pending exception/termination.
110-
void OnUvRead(ssize_t nread, const uv_buf_t* buf);
108+
v8::Maybe<void> OnUvRead(ssize_t nread, const uv_buf_t* buf);
111109

112110
static void AfterUvWrite(uv_write_t* req, int status);
113111
static void AfterUvShutdown(uv_shutdown_t* req, int status);

0 commit comments

Comments
 (0)