Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbcoe <bencoe@google.com>2020-10-09 03:17:01 +0300
committerBenjamin Coe <bencoe@google.com>2020-10-14 01:04:57 +0300
commit7d6672226b93f49d823cd58359f4b2331ca712f5 (patch)
tree2081842f5b6e292a6351438dcc90b8a82ff931e4
parentd7e5d656ea4252231d77de04dc1aa04fcc72abe4 (diff)
fs: rimraf should not recurse on failure
PR-URL: https://github.com/nodejs/node/pull/35566 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
-rw-r--r--lib/internal/fs/rimraf.js5
-rw-r--r--test/known_issues/known_issues.status3
-rw-r--r--test/parallel/test-fs-open-no-close.js (renamed from test/known_issues/test-fs-open-no-close.js)7
-rw-r--r--test/parallel/test-fs-rmdir-recursive.js25
4 files changed, 29 insertions, 11 deletions
diff --git a/lib/internal/fs/rimraf.js b/lib/internal/fs/rimraf.js
index e88dd9697b1..e67b14a418c 100644
--- a/lib/internal/fs/rimraf.js
+++ b/lib/internal/fs/rimraf.js
@@ -12,6 +12,7 @@ const {
} = primordials;
const { Buffer } = require('buffer');
+const fs = require('fs');
const {
chmod,
chmodSync,
@@ -25,7 +26,7 @@ const {
statSync,
unlink,
unlinkSync
-} = require('fs');
+} = fs;
const { sep } = require('path');
const { setTimeout } = require('timers');
const { sleep } = require('internal/util');
@@ -249,7 +250,7 @@ function _rmdirSync(path, options, originalErr) {
for (let i = 1; i <= tries; i++) {
try {
- return rmdirSync(path, options);
+ return fs.rmdirSync(path);
} catch (err) {
// Only sleep if this is not the last try, and the delay is greater
// than zero, and an error was encountered that warrants a retry.
diff --git a/test/known_issues/known_issues.status b/test/known_issues/known_issues.status
index 01a82246c93..e0f0a456089 100644
--- a/test/known_issues/known_issues.status
+++ b/test/known_issues/known_issues.status
@@ -1,3 +1,4 @@
+
prefix known_issues
# If a known issue does not apply to a platform, list the test name in the
@@ -27,5 +28,3 @@ test-vm-timeout-escape-queuemicrotask: SKIP
# The Raspberry Pis are too slow to run this test.
# See https://github.com/nodejs/build/issues/2227#issuecomment-608334574
test-crypto-authenticated-stream: SKIP
-# The bug being checked is that the test never exits.
-test-fs-open-no-close: TIMEOUT
diff --git a/test/known_issues/test-fs-open-no-close.js b/test/parallel/test-fs-open-no-close.js
index ef990d1a67d..5e432dd11d8 100644
--- a/test/known_issues/test-fs-open-no-close.js
+++ b/test/parallel/test-fs-open-no-close.js
@@ -4,14 +4,7 @@
// Failing to close a file should not keep the event loop open.
const common = require('../common');
-
-// This issue only shows up on Raspberry Pi devices in our CI. When this test is
-// moved out of known_issues, this check can be removed, as the test should pass
-// on all platforms at that point.
const assert = require('assert');
-if (process.arch !== 'arm' || process.config.variables.arm_version > 7) {
- assert.fail('This test is for Raspberry Pi devices in CI');
-}
const fs = require('fs');
diff --git a/test/parallel/test-fs-rmdir-recursive.js b/test/parallel/test-fs-rmdir-recursive.js
index 1d2525a5ed6..bbf89a3959e 100644
--- a/test/parallel/test-fs-rmdir-recursive.js
+++ b/test/parallel/test-fs-rmdir-recursive.js
@@ -211,3 +211,28 @@ function removeAsync(dir) {
message: /^The value of "options\.maxRetries" is out of range\./
});
}
+
+// It should not pass recursive option to rmdirSync, when called from
+// rimraf (see: #35566)
+{
+ // Make a non-empty directory:
+ const original = fs.rmdirSync;
+ const dir = `${nextDirPath()}/foo/bar`;
+ fs.mkdirSync(dir, { recursive: true });
+ fs.writeFileSync(`${dir}/foo.txt`, 'hello world', 'utf8');
+
+ // When called the second time from rimraf, the recursive option should
+ // not be set for rmdirSync:
+ let callCount = 0;
+ let rmdirSyncOptionsFromRimraf;
+ fs.rmdirSync = (path, options) => {
+ if (callCount > 0) {
+ rmdirSyncOptionsFromRimraf = { ...options };
+ }
+ callCount++;
+ return original(path, options);
+ };
+ fs.rmdirSync(dir, { recursive: true });
+ fs.rmdirSync = original;
+ assert.strictEqual(rmdirSyncOptionsFromRimraf.recursive, undefined);
+}