Skip to content
Closed
Changes from all 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
35 changes: 26 additions & 9 deletions lib/internal/bootstrap/switches/does_own_process_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ const {
validateString,
validateUint32,
} = require('internal/validators');
const {
codes: {
ERR_INVALID_ARG_TYPE,
ERR_SYSTEM_ERROR,
ERR_UNKNOWN_CREDENTIAL,
},
} = require('internal/errors');

function wrapPosixCredentialSetters(credentials) {
const {
codes: {
ERR_INVALID_ARG_TYPE,
ERR_UNKNOWN_CREDENTIAL,
},
} = require('internal/errors');

const {
initgroups: _initgroups,
setgroups: _setgroups,
Expand Down Expand Up @@ -138,7 +138,24 @@ function wrappedUmask(mask) {
}

function wrappedCwd() {
if (cachedCwd === '')
cachedCwd = rawMethods.cwd();
if (cachedCwd === '') {
try {
cachedCwd = rawMethods.cwd();
} catch (err) {
if (err.code === 'ENOENT') {
const context = {
code: 'ENOENT',
syscall: 'process.cwd',
message:
'The current working directory does not exist. It may have been deleted or unmounted.',
};
const wrapped = new ERR_SYSTEM_ERROR(context);
// Preserve the original error for debugging.
wrapped.cause = err;
throw wrapped;
}
throw err;
}
}
return cachedCwd;
}
Loading