Skip to content

Overriding Sentry.init throws TypeError: Cannot set property init of #<Object> which has only a getter. #2845

Description

@kavitaasiwal

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.21.1

Description

Overriding Sentry.init results in TypeError: 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()
`

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions