Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/internal/bootstrap/switches/does_own_process_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ function wrappedUmask(mask) {
}

function wrappedCwd() {
if (cachedCwd === '')
if (cachedCwd === '') {
cachedCwd = rawMethods.cwd();
}
return cachedCwd;
}
5 changes: 5 additions & 0 deletions src/node_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void OOMErrorHandler(const char* location, const v8::OOMDetails& details);

#define ERRORS_WITH_CODE(V) \
V(ERR_ACCESS_DENIED, Error) \
V(ERR_CWD_DELETED, Error) \
Comment thread
Ankush1oo8 marked this conversation as resolved.
V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, Error) \
V(ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
V(ERR_BUFFER_TOO_LARGE, Error) \
Expand Down Expand Up @@ -160,6 +161,10 @@ ERRORS_WITH_CODE(V)
V(ERR_ACCESS_DENIED, "Access to this API has been restricted") \
V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \
"Buffer is not available for the current Context") \
V(ERR_CWD_DELETED, \
"Current working directory does not exist. " \
"It may have been deleted while the process was still " \
"inside it. Use process.chdir() to change to a valid directory.") \
V(ERR_CLOSED_MESSAGE_PORT, "Cannot send data on closed MessagePort") \
V(ERR_CONSTRUCT_CALL_INVALID, "Constructor cannot be called") \
V(ERR_CONSTRUCT_CALL_REQUIRED, "Cannot call constructor without `new`") \
Expand Down
4 changes: 4 additions & 0 deletions src/node_process_methods.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ static void Cwd(const FunctionCallbackInfo<Value>& args) {
char buf[PATH_MAX_BYTES];
size_t cwd_len = sizeof(buf);
int err = uv_cwd(buf, &cwd_len);
if (err == UV_ENOENT) {
THROW_ERR_CWD_DELETED(env);
return;
}
Comment thread
Ankush1oo8 marked this conversation as resolved.
if (err)
return env->ThrowUVException(err, "uv_cwd");

Expand Down