From 826fb667298ce0f1fa7dd027f7f708e5262f0831 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 29 Apr 2019 21:45:03 +0200 Subject: [PATCH] process: compatibility patch to backport 1d022e8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes sure https://github.com/nodejs/node/pull/27224 is possible to being backported in a semver-patch way. PR-URL: https://github.com/nodejs/node/pull/27483 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: Beth Griggs Reviewed-By: Joyee Cheung Reviewed-By: Shelley Vohr --- lib/internal/main/worker_thread.js | 5 ----- lib/internal/process/main_thread_only.js | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js index 932f282a1bae2c..565cd4a77a15c9 100644 --- a/lib/internal/main/worker_thread.js +++ b/lib/internal/main/worker_thread.js @@ -116,14 +116,9 @@ port.on('message', (message) => { // The counter is only passed to the workers created by the main thread, not // to workers created by other workers. let cachedCwd = ''; - let lastCounter = -1; const originalCwd = process.cwd; process.cwd = function() { - const currentCounter = Atomics.load(cwdCounter, 0); - if (currentCounter === lastCounter) - return cachedCwd; - lastCounter = currentCounter; cachedCwd = originalCwd(); return cachedCwd; }; diff --git a/lib/internal/process/main_thread_only.js b/lib/internal/process/main_thread_only.js index 0cb3edbf9ad7b4..8af402c57a6cb0 100644 --- a/lib/internal/process/main_thread_only.js +++ b/lib/internal/process/main_thread_only.js @@ -39,8 +39,7 @@ function wrapProcessMethods(binding) { } function cwd() { - if (cachedCwd === '') - cachedCwd = binding.cwd(); + cachedCwd = binding.cwd(); return cachedCwd; }