Skip to content

benchmark: throw on invalid type in fs and webstorage - #66647

Open
irontaek wants to merge 1 commit into
nodejs:mainfrom
irontaek:benchmark-throw-invalid-type
Open

irontaek wants to merge 1 commit into
nodejs:mainfrom
irontaek:benchmark-throw-invalid-type

Conversation

@irontaek

Copy link
Copy Markdown

In 21 fs and webstorage benchmarks, the default: branch of the type switch
creates new Error('Invalid type') without throwing it. An unknown type then
falls through and benchmarks an undefined path instead of failing.

Before:

$ node benchmark/fs/bench-existsSync.js type=bogus n=10
fs/bench-existsSync.js n=10 type="bogus": 42,410.43975384981

After, the same command throws Error: Invalid type. Every type listed in each
benchmark's config still has a matching case, so valid runs are unchanged.

Disclosure: this change was found by a static check for discarded new Error(...)
expressions and prepared with a coding agent, which also ran the commands above.
I'll handle review feedback myself.

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
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added benchmark Issues and PRs related to Node.js benchmarks and benchmarking infrastructure. fs Issues and PRs related to file-system APIs and the fs module. labels Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

Caution

AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:automated-account benchmark Issues and PRs related to Node.js benchmarks and benchmarking infrastructure. fs Issues and PRs related to file-system APIs and the fs module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants