Skip to content

Commit b6567ea

Browse files
irontaekaduh95
authored andcommitted
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: #66647 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent 4b810e2 commit b6567ea

21 files changed

Lines changed: 21 additions & 21 deletions

‎benchmark/fs/bench-accessSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function main({ n, type, method }) {
4848
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
4949
break;
5050
default:
51-
new Error('Invalid type');
51+
throw new Error('Invalid type');
5252
}
5353

5454
if (method === 'access') {

‎benchmark/fs/bench-chmodSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ function main({ n, type }) {
3636
bench.end(n);
3737
break;
3838
default:
39-
new Error('Invalid type');
39+
throw new Error('Invalid type');
4040
}
4141
}

‎benchmark/fs/bench-chownSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ function main({ n, type, method }) {
4949
break;
5050
}
5151
default:
52-
new Error('Invalid type');
52+
throw new Error('Invalid type');
5353
}
5454
}

‎benchmark/fs/bench-existsSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function main({ n, type }) {
2727
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
2828
break;
2929
default:
30-
new Error('Invalid type');
30+
throw new Error('Invalid type');
3131
}
3232

3333
bench.start();

‎benchmark/fs/bench-fchmodSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function main({ n, type }) {
2828
files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`));
2929
break;
3030
default:
31-
new Error('Invalid type');
31+
throw new Error('Invalid type');
3232
}
3333

3434
const fds = files.map((x) => {

‎benchmark/fs/bench-fsyncSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function main({ n, type }) {
2424
fd = 1 << 30;
2525
break;
2626
default:
27-
new Error('Invalid type');
27+
throw new Error('Invalid type');
2828
}
2929

3030
bench.start();

‎benchmark/fs/bench-linkSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ function main({ n, type }) {
4545
break;
4646
}
4747
default:
48-
new Error('Invalid type');
48+
throw new Error('Invalid type');
4949
}
5050
}

‎benchmark/fs/bench-mkdirSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function main({ n, type, recursive }) {
2929
files = new Array(n).fill(__dirname);
3030
break;
3131
default:
32-
new Error('Invalid type');
32+
throw new Error('Invalid type');
3333
}
3434

3535
bench.start();

‎benchmark/fs/bench-mkdtempSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function main({ n, type }) {
2727
prefix = tmpdir.resolve('non-existent', 'foo', 'bar');
2828
break;
2929
default:
30-
new Error('Invalid type');
30+
throw new Error('Invalid type');
3131
}
3232

3333
bench.start();

‎benchmark/fs/bench-openSync.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function main({ n, type }) {
3333
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
3434
break;
3535
default:
36-
new Error('Invalid type');
36+
throw new Error('Invalid type');
3737
}
3838

3939
runBench({ n, path });

0 commit comments

Comments
 (0)