Skip to content

Remove IsCallable check for constructor #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025

Conversation

dminor
Copy link
Collaborator

@dminor dminor commented Jul 3, 2025

From my initial telemetry, I think requiring IsCallable(constructor) when the optional constructor argument is present will be web compatible, but I don't have a strong opinion about whether it's worth the bother. Setting up this PR in case we decide to remove this check.

Copy link
Collaborator

@mgaudet mgaudet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@dead-claudia
Copy link

dead-claudia commented Jul 8, 2025

Question: does your telemetry include calls like Error.captureStackTrace(error) or Error.captureStackTrace(error, null), where the constructor is clearly intended to be omitted? Or does it only include stuff like Error.captureStackTrace(error, "foo") and Error.captureStackTrace(error, false)?

Edit: I'm going based off this slide from the agenda post: https://docs.google.com/presentation/d/1RGNDcJee_6N2II0SeGyMVglvjhJbuqDX02LLzBqyCWI/mobilepresent?slide=id.g36c5e1494e7_0_9

@dminor
Copy link
Collaborator Author

dminor commented Jul 10, 2025

Question: does your telemetry include calls like Error.captureStackTrace(error) or Error.captureStackTrace(error, null), where the constructor is clearly intended to be omitted? Or does it only include stuff like Error.captureStackTrace(error, "foo") and Error.captureStackTrace(error, false)?

Edit: I'm going based off this slide from the agenda post: https://docs.google.com/presentation/d/1RGNDcJee_6N2II0SeGyMVglvjhJbuqDX02LLzBqyCWI/mobilepresent?slide=id.g36c5e1494e7_0_9

The actual check is here. If constructor is not undefined, we check to see if it's callable. So we would count Error.captureStackTrace(error, null) as passing in a non-callable constructor.

@dead-claudia
Copy link

I'm curious how the telemetry changes if you exclude null and undefined constructor arguments. 0.8% of calls is still a lot of calls, but I suspect a majority of the calls with a non-callable constructor argument are probably just one of those two. Plus, this PR explicitly ignores undefined in particular, and your Firefox metrics code doesn't check for that to exclude it.

@dminor
Copy link
Collaborator Author

dminor commented Jul 11, 2025

To me it seems kind of strange that people would use Error.captureStackTrace(error, undefined) or Error.captureStackTrace(error, null) rather than just not passing in the constructor argument, but you're right, we could modify the telemetry to handle those cases separately.

That said, maybe we should just land this PR and remove the check, I'm not sure if it's worth potentially causing problems for people. I don't think we'd special case undefined or null in the specification text, for instance.

@dead-claudia
Copy link

To me it seems kind of strange that people would use Error.captureStackTrace(error, undefined) or Error.captureStackTrace(error, null) rather than just not passing in the constructor argument, but you're right, we could modify the telemetry to handle those cases separately.

It seems equally strange to me as well (especially for null), but I see similar idioms all the time in the wild in Stack Overflow and various websites, in code written by less JS-savvy web developers who mainly focus on HTML, CSS, and backend stuff. That's why I called it out.

@dminor dminor merged commit 709fc46 into tc39:main Jul 18, 2025
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.

3 participants