Skip to content
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

isOlderThan is not a function #533

Open
jd-carroll opened this issue May 22, 2024 · 8 comments
Open

isOlderThan is not a function #533

jd-carroll opened this issue May 22, 2024 · 8 comments

Comments

@jd-carroll
Copy link

Environment

    "@sentry/esbuild-plugin": "^2.16.1",

Actual Result

Still investigating, but my builds are all failing with:

  "message": "getHubFromCarrier(...).isOlderThan is not a function",
  "stack": [
    "TypeError: getHubFromCarrier(...).isOlderThan is not a function",
    "    at getGlobalHub (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:6631:33)",
    "    at getCurrentHub (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:6612:10)",
    "    at getClient (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:4967:10)",
    "    at hasTracingEnabled (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:6843:18)",
    "    at sampleTransaction (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:7938:8)",
    "    at Hub._startTransaction (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:8095:17)",
    "    at Hub._callExtensionMethod (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:6555:40)",
    "    at Hub.startTransaction (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:6423:25)",
    "    at _callee$ (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:14342:25)",
    "    at tryCatch (file:///home/runner/work/monorepo/monorepo/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:90:17)"
  ]
@jd-carroll
Copy link
Author

I've been trying to wrap my head around this and cannot seem to be able to.

If I debug locally (I get the same error) and inspecting the registry object it looks like:

  __SENTRY__: {
    extensions: {
      startTransaction: [Function: _startTransaction],
      traceHeaders: [Function: traceHeaders]
    },
    defaultCurrentScope: ScopeClass {
      _notifyingListeners: false,
      _scopeListeners: [],
      _eventProcessors: [],
      _breadcrumbs: [],
      _attachments: [],
      _user: {},
      _tags: {},
      _extra: {},
      _contexts: {},
      _sdkProcessingMetadata: {},
      _propagationContext: [Object]
    },
    defaultIsolationScope: ScopeClass {
      _notifyingListeners: false,
      _scopeListeners: [],
      _eventProcessors: [],
      _breadcrumbs: [],
      _attachments: [],
      _user: {},
      _tags: {},
      _extra: {},
      _contexts: {},
      _sdkProcessingMetadata: {},
      _propagationContext: [Object]
    },
    hub: AsyncContextStack {
      _stack: [Array],
      _isolationScope: [ScopeClass]
    }
  },

I'm not sure where AsyncContextStack would be coming from, but that definitely looks wrong.

Let's go ahead and assume this is something I am doing wrong. Where would I even start?

@jd-carroll
Copy link
Author

Just for tracking purposes, the AsyncContextStack is a Sentry construct. I'm no longer assuming that this is an issue with my code.

Additionally, the AsyncContextStack is created here:
https://github.com/getsentry/sentry-javascript/blob/4420844943418a1bc23a6ccad70401d68a8c94a4/packages/core/src/asyncContext/stackStrategy.ts#L133-L148

@lforst
Copy link
Member

lforst commented May 22, 2024

Can you try setting telemetry: false? Thanks!

@Lms24
Copy link
Member

Lms24 commented May 22, 2024

Hey @jd-carroll - this is most likely fixed by getsentry/sentry-javascript#12160 which we're gonna release today.

@jd-carroll
Copy link
Author

@Lms24 awesome, thank you, I'll look for that in a bit!

@lforst I tried setting that but it still seems to be throwing the same error (but maybe less...?)

Additionally, I just noticed this in the error output:

        {
          "id": "import-is-undefined",
          "location": {
            "column": 44,
            "file": "lambdas/user-account-setup-handler/user-account-setup-handler.ts?sentryProxyModule=true",
            "length": 7,
            "line": 4,
            "lineText": "              export default OriginalModule.default;",
            "namespace": "",
            "suggestion": ""
          },
          "notes": [],
          "pluginName": "",
          "text": "Import \"default\" will always be undefined because there is no matching export in \"lambdas/user-account-setup-handler/user-account-setup-handler.ts\""
        }

I didn't think the Sentry bundler is actually changing the entry point for the lambda. If so, this is hugely concerning because none of my lambdas use "default" as the named entry point for AWS.

Can either of you help me understand what is happening there?

@jd-carroll
Copy link
Author

As a side note, I just patched my local code and everything seems to be working. I also inspected the output and confirmed that my named exports still exist. The output contains the following:

// lambdas/user-account-details-handler/user-account-details-handler.ts?sentryProxyModule=true
var user_account_details_handler_default = void 0;
export {
  user_account_details_handler_default as default,
  handler
};
//# sourceMappingURL=lambda.mjs.map

Nothing is ever assigned to user_account_details_handler_default other than void 0. So my assumption would be it is something you look for in the uploaded sourcemaps to Sentry? Either way, no big deal, more so curious now... 😄

@jd-carroll
Copy link
Author

@Lms24 It does not appear this was fixed in @sentry/core@8.3.0 (fyi)

@Lms24
Copy link
Member

Lms24 commented May 22, 2024

Yup, sorry about that, we had to close the PR in favor of a better fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Development

Successfully merging a pull request may close this issue.

4 participants