Skip to content

Conversation

@Jack-Works
Copy link
Contributor

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

const context = getOriginalFunction(this) || this;
return originalFunctionToString.apply(context, args);
};
try {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment here for why this try-catch exists? For future reference :) Would also be nice to have an example when/why this may be frozen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for example:

pwsh> node --frozen-intrinsics
(node:26089) ExperimentalWarning: The --frozen-intrinsics flag is experimental
(Use `node --trace-warnings ...` to show where the warning was created)
Welcome to Node.js v19.9.0.
Type ".help" for more information.
> 'use strict'; Function.prototype.toString = function () { return '' }
Uncaught:
TypeError <Object <Object <[Object: null prototype] {}>>>: Cannot assign to read only property 'toString' of object 'function () { [native code] }'
    at Function.setter (node:internal/freeze_intrinsics:499:17)

image

Copy link
Member

Choose a reason for hiding this comment

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

thanks, that's perfect!

@mydea mydea self-assigned this Apr 19, 2023
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@mydea mydea changed the title Avoid crash when Function.prototype is frozen fix(core): Avoid crash when Function.prototype is frozen Apr 19, 2023
@mydea mydea merged commit c74eff8 into getsentry:develop Apr 20, 2023
@Jack-Works Jack-Works deleted the patch-1 branch April 21, 2023 03:36
@mydea
Copy link
Member

mydea commented Apr 27, 2023

Hi @Jack-Works ,

this has been released in v7.50.0!

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.

2 participants