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

feat(core): Move globals to __SENTRY__ singleton #11034

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Mar 11, 2024

This PR moves globalScope and globalMetricsAggregators to the __SENTRY__ global singleton.

This means that if the files that these globals are in get bundled or different versions of @sentry/core are used, we can be sure that they'll still access the same globals.

@timfish timfish marked this pull request as ready for review March 11, 2024 21:06
@timfish timfish requested a review from AbhiPrasad March 11, 2024 23:35
@mydea
Copy link
Member

mydea commented Mar 12, 2024

This is good, I also wanted to do that!
Just one thing, could we also move the defaultCurrentScope & defaultIsolationScope there? I guess the same things apply there.

@timfish
Copy link
Collaborator Author

timfish commented Mar 12, 2024

could we also move the defaultCurrentScope & defaultIsolationScope

Possibly. I was looking through hub.ts and it appears that much of that file will be gone for v8? Will defaultCurrentScope and defaultIsolationScope still be required?

@AbhiPrasad
Copy link
Member

Will defaultCurrentScope and defaultIsolationScope still be required

it will as per getsentry/rfcs#122

@timfish
Copy link
Collaborator Author

timfish commented Mar 12, 2024

Ah, I think it's the default* naming that confused me. These are simply the currentScope and isolationScope?

What happens when Hub is gone, will there need to be a new type to store the scopes that can be saved in the async storage? { current: Scope, isolation: Scope}

Ahhhhh ok, so are defaultCurrentScope and defaultIsolationScope only the current and isolation scopes when no async storage exists? ie. the fallback used in the browser (for now) and also when nothing was found in the async storage?

@mydea
Copy link
Member

mydea commented Mar 12, 2024

Ah, I think it's the default* naming that confused me. These are simply the currentScope and isolationScope?

What happens when Hub is gone, will there need to be a new type to store the scopes that can be saved in the async storage? { current: Scope, isolation: Scope}

Ahhhhh ok, so are defaultCurrentScope and defaultIsolationScope only the current and isolation scopes when no async storage exists? ie. the fallback used in the browser (for now) and also when nothing was found in the async storage?

They are basically the initial current/isolation scope - so if no async context is forked off yet, these will be the ones that are used - exactly! :)

@AbhiPrasad AbhiPrasad merged commit 34d7e41 into develop Mar 12, 2024
91 checks passed
@AbhiPrasad AbhiPrasad deleted the timfish/move-globals-to-sentry branch March 12, 2024 16:35
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