Skip to content

Commit a7cce7b

Browse files
authored
fix(node): Remove dom lib types (#9090)
I've been having issues with the `setTimeout` return type in the node SDK, mostly when running tests: ``` Property 'unref' does not exist on type 'number'. ``` It turns out we've got dom lib types in the base tsconfig which means these have ended up in node SDK. This PR ensures we only have `es6` and no dom lib types and then fixes all the resulting errors.
1 parent 622186c commit a7cce7b

File tree

5 files changed

+8
-13
lines changed

5 files changed

+8
-13
lines changed

packages/node/src/integrations/undici/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Vendored from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/5a94716c6788f654aea7999a5fc28f4f1e7c48ad/types/node/diagnostics_channel.d.ts
22

33
import type { Span } from '@sentry/core';
4+
import type { URL } from 'url';
45

56
// License:
67
// This project is licensed under the MIT license.
@@ -224,7 +225,7 @@ export interface UndiciRequest {
224225
method?: string;
225226
path: string;
226227
headers: string;
227-
addHeader(key: string, value: string): Request;
228+
addHeader(key: string, value: string): RequestWithSentry;
228229
}
229230

230231
export interface UndiciResponse {

packages/node/src/requestdata.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,5 @@ function extractQueryParams(req: PolymorphicRequest): string | Record<string, un
320320
originalUrl = `http://dogs.are.great${originalUrl}`;
321321
}
322322

323-
return (
324-
req.query ||
325-
(typeof URL !== undefined && new URL(originalUrl).search.replace('?', '')) ||
326-
// In Node 8, `URL` isn't in the global scope, so we have to use the built-in module from Node
327-
url.parse(originalUrl).query ||
328-
undefined
329-
);
323+
return req.query || new url.URL(originalUrl).search.replace('?', '') || undefined;
330324
}

packages/node/test/async/domain.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe('domains', () => {
119119
if (d2done) {
120120
done();
121121
}
122-
});
122+
}, 0);
123123
});
124124

125125
runWithAsyncContext(() => {
@@ -131,7 +131,7 @@ describe('domains', () => {
131131
if (d1done) {
132132
done();
133133
}
134-
});
134+
}, 0);
135135
});
136136
});
137137
});

packages/node/test/async/hooks.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ conditionalTest({ min: 12 })('async_hooks', () => {
130130
if (d2done) {
131131
done();
132132
}
133-
});
133+
}, 0);
134134
});
135135

136136
runWithAsyncContext(() => {
@@ -142,7 +142,7 @@ conditionalTest({ min: 12 })('async_hooks', () => {
142142
if (d1done) {
143143
done();
144144
}
145-
});
145+
}, 0);
146146
});
147147
});
148148
});

packages/node/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"include": ["src/**/*"],
55

66
"compilerOptions": {
7-
// package-specific options
7+
"lib": ["es6"]
88
}
99
}

0 commit comments

Comments
 (0)