Skip to content

Commit

Permalink
fix(astro): Ensure server-side exports work correctly (#12453)
Browse files Browse the repository at this point in the history
Fix a server-side re-export problem of `@sentry/node` exports
in the Astro SDK. It seems that the `export * from '@sentry/node'` "overruled" the
explicit exports. So this patch changes our export statements to:
- only export explicit, named exports in the JS server side entry point
- continue exporting all types via the `*` export in the types entry
point

fixes #12410
  • Loading branch information
Lms24 committed Jun 11, 2024
1 parent 1014da2 commit cc7db73
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
30 changes: 27 additions & 3 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,35 @@ export {
setupHapiErrorHandler,
spotlightIntegration,
addOpenTelemetryInstrumentation,
metrics,
NodeClient,
addIntegration,
anrIntegration,
captureConsoleIntegration,
captureSession,
connectIntegration,
createGetModuleFromFilename,
debugIntegration,
dedupeIntegration,
endSession,
extraErrorDataIntegration,
getAutoPerformanceIntegrations,
httpIntegration,
initOpenTelemetry,
koaIntegration,
nativeNodeFetchIntegration,
rewriteFramesIntegration,
sessionTimingIntegration,
setupConnectErrorHandler,
setupKoaErrorHandler,
spanToBaggageHeader,
spanToJSON,
spanToTraceHeader,
startSession,
trpcMiddleware,
zodErrorsIntegration,
} from '@sentry/node';

// We can still leave this for the carrier init and type exports
export * from '@sentry/node';

export { init } from './server/sdk';

export default sentryAstro;
Expand Down
7 changes: 5 additions & 2 deletions packages/astro/src/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// exports in this file - which we do below.
export * from './index.client';
export * from './index.server';
export * from '@sentry/node';

import type { NodeOptions } from '@sentry/node';

import type { Integration, Options, StackParser } from '@sentry/types';

Expand All @@ -11,7 +14,7 @@ import type * as serverSdk from './index.server';
import sentryAstro from './index.server';

/** Initializes Sentry Astro SDK */
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): void;
export declare function init(options: Options | clientSdk.BrowserOptions | NodeOptions): void;

export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
Expand All @@ -29,5 +32,5 @@ export declare const continueTrace: typeof clientSdk.continueTrace;

export declare const Span: clientSdk.Span;

export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk;
export default sentryAstro;
1 change: 1 addition & 0 deletions packages/astro/src/server/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function init(options: NodeOptions): void {
const opts = {
...options,
};

applySdkMetadata(opts, 'astro', ['astro', 'node']);

initNodeSdk(opts);
Expand Down

0 comments on commit cc7db73

Please sign in to comment.