Skip to content

fix(ext/node): support options-only overload in util.getCallSites - #37141

Open
Sun-Wukhan wants to merge 2 commits into
denoland:mainfrom
Sun-Wukhan:fix-getcallsites-options-overload
Open

Sun-Wukhan wants to merge 2 commits into
denoland:mainfrom
Sun-Wukhan:fix-getcallsites-options-overload

Conversation

@Sun-Wukhan

Copy link
Copy Markdown

Fixes #37136

util.getCallSites() validated the first argument as frameCount unconditionally, so the options-only overload that the type declarations accept (and Node accepts) threw ERR_INVALID_ARG_TYPE. Provided options were also validated only when truthy, so getCallSites(10, null), (10, false), (10, 0) and (10, "") were silently accepted instead of being rejected.

This restructures the argument handling to match Node's lib/util.js: when options is omitted and the first argument is an object, it is treated as the options object with the default frame count of 10. Provided options are always validated with validateObject, and options.sourceMap is validated with validateBoolean when present. Deno's existing validateNumber range for frameCount (0 to 200) is unchanged.

Adds a unit test covering the options-only overload, the default frame count, and rejection of falsy or invalid options. Behaviour was checked against Node v24 for the affected call shapes, and the bug was reproduced on Deno 2.9.8 before the change.

AI disclosure: this PR was prepared with AI assistance (Claude), as required by the contributing guidelines.

Signed-off-by: Navid Khan (Ali) <60997541+Sun-Wukhan@users.noreply.github.com>
Signed-off-by: Navid Khan (Ali) <60997541+Sun-Wukhan@users.noreply.github.com>
@CLAassistant

CLAassistant commented Nov 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node:util.getCallSites rejects the options-only overload

2 participants