Skip to content
Browse files

fs: don't assert on uv_fs_*() errors

Pass errors to the JS callbacks, don't assert in C++ land.

Fixes among other things the case where Node aborts because uv_fs_futimes()
returns ENOSYS.
  • Loading branch information...
1 parent 0f33768 commit 2156e5eca10d1dc3bb8155dc70f1dc0718841028 @shigeki shigeki committed with bnoordhuis
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/node_file.cc
View
10 src/node_file.cc
@@ -226,11 +226,17 @@ struct fs_req_wrap {
#define ASYNC_CALL(func, callback, ...) \
FSReqWrap* req_wrap = new FSReqWrap(); \
- int r = uv_fs_##func(Loop(), &req_wrap->req_, \
+ int r = uv_fs_##func(Loop(), &req_wrap->req_, \
__VA_ARGS__, After); \
- assert(r == 0); \
req_wrap->object_->Set(oncomplete_sym, callback); \
req_wrap->Dispatched(); \
+ if (r < 0) { \
+ uv_fs_t* req = &req_wrap->req_; \
+ req->result = r; \
+ req->path = NULL; \
+ req->errorno = uv_last_error(uv_default_loop()).code; \
@shigeki
shigeki added a note

Is uv_default_loop() to be Loop() after isolate supported?

@bnoordhuis Node.js Foundation member

Good catch, I missed that one. Fixed in 4e52477.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ After(req); \
+ } \
return scope.Close(req_wrap->object_);
#define SYNC_CALL(func, path, ...) \

0 comments on commit 2156e5e

Please sign in to comment.
Something went wrong with that request. Please try again.