Skip to content

Commit

Permalink
fix(node): Remove dom lib types (#9090)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timfish authored Sep 25, 2023
1 parent 622186c commit a7cce7b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
3 changes: 2 additions & 1 deletion packages/node/src/integrations/undici/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Vendored from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/5a94716c6788f654aea7999a5fc28f4f1e7c48ad/types/node/diagnostics_channel.d.ts

import type { Span } from '@sentry/core';
import type { URL } from 'url';

// License:
// This project is licensed under the MIT license.
Expand Down Expand Up @@ -224,7 +225,7 @@ export interface UndiciRequest {
method?: string;
path: string;
headers: string;
addHeader(key: string, value: string): Request;
addHeader(key: string, value: string): RequestWithSentry;
}

export interface UndiciResponse {
Expand Down
8 changes: 1 addition & 7 deletions packages/node/src/requestdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,5 @@ function extractQueryParams(req: PolymorphicRequest): string | Record<string, un
originalUrl = `http://dogs.are.great${originalUrl}`;
}

return (
req.query ||
(typeof URL !== undefined && new URL(originalUrl).search.replace('?', '')) ||
// In Node 8, `URL` isn't in the global scope, so we have to use the built-in module from Node
url.parse(originalUrl).query ||
undefined
);
return req.query || new url.URL(originalUrl).search.replace('?', '') || undefined;
}
4 changes: 2 additions & 2 deletions packages/node/test/async/domain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('domains', () => {
if (d2done) {
done();
}
});
}, 0);
});

runWithAsyncContext(() => {
Expand All @@ -131,7 +131,7 @@ describe('domains', () => {
if (d1done) {
done();
}
});
}, 0);
});
});
});
4 changes: 2 additions & 2 deletions packages/node/test/async/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ conditionalTest({ min: 12 })('async_hooks', () => {
if (d2done) {
done();
}
});
}, 0);
});

runWithAsyncContext(() => {
Expand All @@ -142,7 +142,7 @@ conditionalTest({ min: 12 })('async_hooks', () => {
if (d1done) {
done();
}
});
}, 0);
});
});
});
2 changes: 1 addition & 1 deletion packages/node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"include": ["src/**/*"],

"compilerOptions": {
// package-specific options
"lib": ["es6"]
}
}

0 comments on commit a7cce7b

Please sign in to comment.