Skip to content

Commit

Permalink
doc: Add clarifying comment for hub on ACS (#11633)
Browse files Browse the repository at this point in the history
Added a comment for
#11630 (comment)!
  • Loading branch information
mydea authored Apr 16, 2024
1 parent 0d2c960 commit 919f60b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/core/src/asyncContext/stackStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,13 @@ export class AsyncContextStack {
*/
function getAsyncContextStack(): AsyncContextStack {
const registry = getMainCarrier();

// For now we continue to keep this as `hub` on the ACS,
// as e.g. the Loader Script relies on this.
// Eventually we may change this if/when we update the loader to not require this field anymore
// Related, we also write to `hub` in {@link ./../sdk.ts registerClientOnGlobalHub}
const sentry = getSentryCarrier(registry) as { hub?: AsyncContextStack };

// If there's no hub, or its an old API, assign a new one
if (sentry.hub) {
return sentry.hub;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export function setCurrentClient(client: Client): void {
}

/**
* Unfortunately, we still have to manually bind the client to the "hub" set on the global
* Unfortunately, we still have to manually bind the client to the "hub" property set on the global
* Sentry carrier object. This is because certain scripts (e.g. our loader script) obtain
* the client via `window.__SENTRY__.hub.getClient()`.
*
* @see {@link hub.ts getGlobalHub}
* @see {@link ./asyncContext/stackStrategy.ts getAsyncContextStack}
*/
function registerClientOnGlobalHub(client: Client): void {
const sentryGlobal = getSentryCarrier(getMainCarrier()) as { hub?: AsyncContextStack };
Expand Down

0 comments on commit 919f60b

Please sign in to comment.