mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
When mkdir() fails with ENOENT, the recursive algorithm assumes the
parent is missing, creates it and retries. On procfs mkdir() keeps
returning ENOENT although the parent exists, and under a concurrent
rmdir() the parent can disappear again, so the retry loop never
terminates: `fs.mkdirSync('/proc/x', { recursive: true })` spins at
100% CPU.
Retry a path that failed with ENOENT only once and report ENOENT the
second time, like the non-recursive call does.
Fixes: https://github.com/nodejs/node/issues/66268
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66340
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
24 lines
625 B
JavaScript
24 lines
625 B
JavaScript
'use strict';
|
|
|
|
// This tests heap snapshot integration of a pending recursive mkdir.
|
|
|
|
const common = require('../common');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const { validateByRetainingPath } = require('../common/heap');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
|
|
tmpdir.refresh();
|
|
|
|
{
|
|
const nodes = validateByRetainingPath('Node / FSContinuationData', []);
|
|
assert.strictEqual(nodes.length, 0);
|
|
}
|
|
|
|
fs.mkdir(tmpdir.resolve('a', 'b'), { recursive: true }, common.mustSucceed());
|
|
|
|
{
|
|
const nodes = validateByRetainingPath('Node / FSContinuationData', []);
|
|
assert.strictEqual(nodes.length, 1);
|
|
}
|