Skip to content

Commit 18a342f

Browse files
author
Luca Forstner
authored
fix(node): Fix type definitions (#10339)
1 parent 12299c9 commit 18a342f

File tree

7 files changed

+58
-12
lines changed

7 files changed

+58
-12
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,32 @@ jobs:
727727
cd packages/utils
728728
yarn test:package
729729
730+
job_check_for_faulty_dts:
731+
name: Check for faulty .d.ts files
732+
needs: [job_get_metadata, job_build]
733+
runs-on: ubuntu-20.04
734+
timeout-minutes: 5
735+
steps:
736+
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
737+
uses: actions/checkout@v4
738+
with:
739+
ref: ${{ env.HEAD_COMMIT }}
740+
- name: Set up Node
741+
uses: actions/setup-node@v4
742+
with:
743+
node-version-file: 'package.json'
744+
- name: Restore caches
745+
uses: ./.github/actions/restore-cache
746+
env:
747+
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
748+
- name: Check for dts files that reference stuff in the temporary build folder
749+
run: |
750+
if grep -r --include "*.d.ts" --exclude-dir ".nxcache" 'import("@sentry(-internal)?/[^/]*/build' .; then
751+
echo "Found illegal TypeScript import statement."
752+
exit 1
753+
fi
754+
755+
730756
job_node_integration_tests:
731757
name:
732758
Node (${{ matrix.node }})${{ (matrix.typescript && format(' (TS {0})', matrix.typescript)) || '' }} Integration

packages/node/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ const INTEGRATIONS = {
127127
...TracingIntegrations,
128128
};
129129

130+
// TODO(v8): Remove all of these exports. They were part of a hotfix #10339 where we produced wrong .d.ts files because we were packing packages inside the /build folder.
131+
export type { LocalVariablesIntegrationOptions } from './integrations/local-variables/common';
132+
export type { DebugSession } from './integrations/local-variables/local-variables-sync';
133+
export type { AnrIntegrationOptions } from './integrations/anr/common';
134+
export { Undici } from './integrations/undici';
135+
export { Http } from './integrations/http';
136+
// ---
137+
130138
export { INTEGRATIONS as Integrations, Handlers };
131139

132140
export { hapiErrorPlugin } from './integrations/hapi';

packages/node/src/integrations/anr/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Contexts, DsnComponents, Primitive, SdkMetadata } from '@sentry/types';
22

3-
export interface Options {
3+
export interface AnrIntegrationOptions {
44
/**
55
* Interval to send heartbeat messages to the ANR worker.
66
*
@@ -33,7 +33,7 @@ export interface Options {
3333
appRootPath: string | undefined;
3434
}
3535

36-
export interface WorkerStartData extends Options {
36+
export interface WorkerStartData extends AnrIntegrationOptions {
3737
debug: boolean;
3838
sdkMetadata: SdkMetadata;
3939
dsn: DsnComponents;

packages/node/src/integrations/anr/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { dynamicRequire, logger } from '@sentry/utils';
66
import type { Worker, WorkerOptions } from 'worker_threads';
77
import type { NodeClient } from '../../client';
88
import { NODE_VERSION } from '../../nodeVersion';
9-
import type { Options, WorkerStartData } from './common';
9+
import type { AnrIntegrationOptions, WorkerStartData } from './common';
1010
import { base64WorkerScript } from './worker-script';
1111

1212
const DEFAULT_INTERVAL = 50;
@@ -52,7 +52,7 @@ interface InspectorApi {
5252

5353
const INTEGRATION_NAME = 'Anr';
5454

55-
const anrIntegration = ((options: Partial<Options> = {}) => {
55+
const anrIntegration = ((options: Partial<AnrIntegrationOptions> = {}) => {
5656
return {
5757
name: INTEGRATION_NAME,
5858
// TODO v8: Remove this
@@ -77,13 +77,13 @@ const anrIntegration = ((options: Partial<Options> = {}) => {
7777
export const Anr = convertIntegrationFnToClass(INTEGRATION_NAME, anrIntegration) as IntegrationClass<
7878
Integration & { setup: (client: NodeClient) => void }
7979
> & {
80-
new (options?: Partial<Options>): Integration & { setup(client: Client): void };
80+
new (options?: Partial<AnrIntegrationOptions>): Integration & { setup(client: Client): void };
8181
};
8282

8383
/**
8484
* Starts the ANR worker thread
8585
*/
86-
async function _startWorker(client: NodeClient, _options: Partial<Options>): Promise<void> {
86+
async function _startWorker(client: NodeClient, _options: Partial<AnrIntegrationOptions>): Promise<void> {
8787
const contexts = await getContexts(client);
8888
const dsn = client.getDsn();
8989

packages/node/src/integrations/local-variables/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export interface FrameVariables {
9595
vars?: Variables;
9696
}
9797

98-
export interface Options {
98+
export interface LocalVariablesIntegrationOptions {
9999
/**
100100
* Capture local variables for both caught and uncaught exceptions
101101
*

packages/node/src/integrations/local-variables/local-variables-async.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import type { Debugger, InspectorNotification, Runtime } from 'inspector';
66

77
import type { NodeClient } from '../../client';
88
import type { NodeClientOptions } from '../../types';
9-
import type { FrameVariables, Options, PausedExceptionEvent, RateLimitIncrement, Variables } from './common';
9+
import type {
10+
FrameVariables,
11+
LocalVariablesIntegrationOptions,
12+
PausedExceptionEvent,
13+
RateLimitIncrement,
14+
Variables,
15+
} from './common';
1016
import { createRateLimiter, functionNamesMatch, hashFrames, hashFromStack } from './common';
1117

1218
async function unrollArray(session: Session, objectId: string, name: string, vars: Variables): Promise<void> {
@@ -70,7 +76,7 @@ const INTEGRATION_NAME = 'LocalVariablesAsync';
7076
/**
7177
* Adds local variables to exception frames
7278
*/
73-
const localVariablesAsyncIntegration = ((options: Options = {}) => {
79+
const localVariablesAsyncIntegration = ((options: LocalVariablesIntegrationOptions = {}) => {
7480
const cachedFrames: LRUMap<string, FrameVariables[]> = new LRUMap(20);
7581
let rateLimiter: RateLimitIncrement | undefined;
7682
let shouldProcessEvent = false;

packages/node/src/integrations/local-variables/local-variables-sync.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import type { Debugger, InspectorNotification, Runtime, Session } from 'inspecto
66
import type { NodeClient } from '../../client';
77

88
import { NODE_VERSION } from '../../nodeVersion';
9-
import type { FrameVariables, Options, PausedExceptionEvent, RateLimitIncrement, Variables } from './common';
9+
import type {
10+
FrameVariables,
11+
LocalVariablesIntegrationOptions,
12+
PausedExceptionEvent,
13+
RateLimitIncrement,
14+
Variables,
15+
} from './common';
1016
import { createRateLimiter, functionNamesMatch, hashFrames, hashFromStack } from './common';
1117

1218
type OnPauseEvent = InspectorNotification<Debugger.PausedEventDataType>;
@@ -214,7 +220,7 @@ const INTEGRATION_NAME = 'LocalVariables';
214220
* Adds local variables to exception frames
215221
*/
216222
const localVariablesSyncIntegration = ((
217-
options: Options = {},
223+
options: LocalVariablesIntegrationOptions = {},
218224
session: DebugSession | undefined = tryNewAsyncSession(),
219225
) => {
220226
const cachedFrames: LRUMap<string, FrameVariables[]> = new LRUMap(20);
@@ -394,5 +400,5 @@ export const LocalVariablesSync = convertIntegrationFnToClass(
394400
INTEGRATION_NAME,
395401
localVariablesSyncIntegration,
396402
) as IntegrationClass<Integration & { processEvent: (event: Event) => Event; setup: (client: NodeClient) => void }> & {
397-
new (options?: Options, session?: DebugSession): Integration;
403+
new (options?: LocalVariablesIntegrationOptions, session?: DebugSession): Integration;
398404
};

0 commit comments

Comments
 (0)