Skip to content

Conversation

@lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Oct 15, 2021

Multiple times over the years, we've had to rearrange code in @sentry/utils in order to not end up with one or more circular dependencies. Often this has been a logger -> misc -> logger cycle, since each of them contained very low-level code. Having just hit it again, I decided to stop making piecemeal fixes and actually organize things so that it will stop happening once and for all. To do that, I made three changes:

  • I moved getGlobalObject to its own module.
  • I moved consoleSandbox into the logger module itself, since that's the only place it's used.
  • Given how easy it would be to recreate this problem - just add to logger.ts's dependencies (not knowing that that's what they are) any function which logs to the console using the logger - I added a warning comment at the top of both dependencies.

While I was moving things around, I noticed that when I'd separated out node.ts and browser.ts (in order to fix an earlier incarnation of this very same problem), I'd missed moving getLocationHref into the browser module, so I did that here, too.

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Nice

@github-actions
Copy link
Contributor

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 22.36 KB (+0.13% 🔺)
@sentry/browser - Webpack 23.24 KB (-0.32% 🔽)
@sentry/react - Webpack 23.27 KB (-0.32% 🔽)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 29.8 KB (+0.03% 🔺)

@lobsterkatie lobsterkatie merged commit 84a6dc0 into master Oct 15, 2021
@lobsterkatie lobsterkatie deleted the kmclb-stop-logger-circular-dependencies branch October 15, 2021 21:29
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