-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Overriding Sentry.init
throws TypeError: Cannot set property init of #<Object> which has only a getter
.
#2845
Comments
Hey thanks for reporting. We know this is an issue as it was raised by some other users previously. Just curious though, why did you choose to override
and then import We are currently trying to determine if we should roll back the change from the typescript upgrade, so if others arrive on this issue, please comment with your situation and use case. |
Thanks for the quick response Abhijeet! The only reason we decided to overwrite I am going to add our own init function to guard against future breakages but it would be nice if this issue is fixed so that our existing users on the previous version don't start breaking. |
Hey there! Thanks for the library. I think we've seen a similar issue as a result of this change. In tests, we're using sinon to stub/fake/spy methods on Sentry, and assert that they're called correctly, eg sinon.spy(Sentry, 'captureException');
doStuff();
expect(Sentry.captureException).to.have.been.calledOnceWithExactly("foo"); Previously this was okay, but since the TypeScript bump sinon is unable to set up the spy: I imagine we could solve this with an application-specific |
Cool, thank you for your feedback. We have decided to rollback the typescript change to fix this, and we will better communicate typescript upgrades in the future to prevent situations like this. |
Package + Version
@sentry/browser
@sentry/node
raven-js
raven-node
(raven for node)Version:
Description
Overriding
Sentry.init
results inTypeError: Cannot set property init of #<Object> which has only a getter
.With the typescript upgrade to v3.9.7 in v5.21.1, the init export has changed unexpectedly.
It changed from -
var sdk_1 = require("./sdk"); exports.init = sdk_1.init;
to -
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return sdk_1.init; } });
Previously, one could use the following to override Sentry.init which does not work anymore -
`const Sentry = require('@sentry/node');
Sentry.init = (options) => {
init({
dsn: ...
...options
});
Sentry.init()
`
The text was updated successfully, but these errors were encountered: