benchmark: throw on invalid type in fs and webstorage

The default branch of the type switch constructed an Error without
throwing it, so an unknown type silently benchmarked an undefined
path instead of failing.

Assisted-by: a closed-source coding agent
Signed-off-by: Minho Yoo <13810291+irontaek@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/66647
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
Minho Yoo authored and Antoine du Hamel committed 2026-11-23 12:34:21 +01:00
1 parent 4b810e2c5e
commit b6567ea812
21 files changed
+21 -21

No files matched your search

+1 -1
View File
@@ -48,7 +48,7 @@ function main({ n, type, method }) {
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
if (method === 'access') {
+1 -1
View File
@@ -36,6 +36,6 @@ function main({ n, type }) {
bench.end(n);
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -49,6 +49,6 @@ function main({ n, type, method }) {
break;
}
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ function main({ n, type }) {
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
bench.start();
+1 -1
View File
@@ -28,7 +28,7 @@ function main({ n, type }) {
files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`));
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
const fds = files.map((x) => {
+1 -1
View File
@@ -24,7 +24,7 @@ function main({ n, type }) {
fd = 1 << 30;
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
bench.start();
+1 -1
View File
@@ -45,6 +45,6 @@ function main({ n, type }) {
break;
}
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -29,7 +29,7 @@ function main({ n, type, recursive }) {
files = new Array(n).fill(__dirname);
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
bench.start();
+1 -1
View File
@@ -27,7 +27,7 @@ function main({ n, type }) {
prefix = tmpdir.resolve('non-existent', 'foo', 'bar');
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
bench.start();
+1 -1
View File
@@ -33,7 +33,7 @@ function main({ n, type }) {
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
runBench({ n, path });
+1 -1
View File
@@ -25,7 +25,7 @@ function main({ n, type }) {
files = [tmpdir.resolve(`.non-existing-file-${Date.now()}`)];
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
bench.start();
+1 -1
View File
@@ -38,7 +38,7 @@ function main({ n, type }) {
fd = 1 << 30;
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
const buffer = Buffer.alloc(bufferSize);
+1 -1
View File
@@ -49,6 +49,6 @@ function main({ n, type }) {
break;
}
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -37,6 +37,6 @@ function main({ n, type }) {
break;
}
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -46,6 +46,6 @@ function main({ n, type }) {
break;
}
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -56,6 +56,6 @@ function main({ n, type, func }) {
break;
}
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ function main({ n, type }) {
files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`));
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
bench.start();
+1 -1
View File
@@ -24,7 +24,7 @@ function main({ n, type }) {
fd = 1 << 30;
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
bench.start();
+1 -1
View File
@@ -70,6 +70,6 @@ function main({ n, type }) {
bench.end(n);
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -70,6 +70,6 @@ function main({ n, type }) {
bench.end(n);
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}
+1 -1
View File
@@ -58,6 +58,6 @@ function main({ n, type }) {
bench.end(n);
break;
default:
new Error('Invalid type');
throw new Error('Invalid type');
}
}