Skip to content

Commit 18a272f

Browse files
authored
Merge branch 'v8' into v8-upgrade-otel-deps
2 parents 45044bb + 5f47fbb commit 18a272f

File tree

10 files changed

+59
-37
lines changed

10 files changed

+59
-37
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,8 @@ jobs:
738738
node_version: ${{ matrix.node == 14 && '14' || '' }}
739739

740740
- name: Overwrite typescript version
741-
if: matrix.typescript
742-
run: node ./scripts/use-ts-version.js ${{ matrix.typescript }}
741+
if: matrix.typescript == '3.8'
742+
run: node ./scripts/use-ts-3_8.js
743743
working-directory: dev-packages/node-integration-tests
744744

745745
- name: Run integration tests

.size-limit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = [
5454
path: 'packages/browser/build/npm/esm/index.js',
5555
import: createImport('init', 'browserTracingIntegration', 'replayIntegration'),
5656
gzip: true,
57-
limit: '68 KB',
57+
limit: '68.5 KB',
5858
modifyWebpackConfig: function (config) {
5959
const webpack = require('webpack');
6060
const TerserPlugin = require('terser-webpack-plugin');

dev-packages/e2e-tests/test-applications/nestjs-fastify/src/app.controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Controller, Get, Param, ParseIntPipe, UseFilters, UseGuards, UseInterceptors } from '@nestjs/common';
1+
import { All, Controller, Get, Param, ParseIntPipe, UseFilters, UseGuards, UseInterceptors } from '@nestjs/common';
22
import { flush } from '@sentry/nestjs';
33
import { AppService } from './app.service';
44
import { AsyncInterceptor } from './async-example.interceptor';
@@ -121,4 +121,9 @@ export class AppController {
121121
testFunctionName() {
122122
return this.appService.getFunctionName();
123123
}
124+
125+
@All('test-all')
126+
testAll() {
127+
return {};
128+
}
124129
}

dev-packages/e2e-tests/test-applications/nestjs-fastify/tests/transactions.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,8 @@ test('Calling canActivate method on service with Injectable decorator returns 20
808808
const response = await fetch(`${baseURL}/test-service-canActivate`);
809809
expect(response.status).toBe(200);
810810
});
811+
812+
test('Calling @All method on service with Injectable decorator returns 200', async ({ baseURL }) => {
813+
const response = await fetch(`${baseURL}/test-all`);
814+
expect(response.status).toBe(200);
815+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* eslint-disable no-console */
2+
const { execSync } = require('child_process');
3+
const { join } = require('path');
4+
const { readFileSync, writeFileSync } = require('fs');
5+
6+
const cwd = join(__dirname, '../../..');
7+
8+
// Newer versions of the Express types use syntax that isn't supported by TypeScript 3.8.
9+
// We'll pin to the last version of those types that are compatible.
10+
console.log('Pinning Express types to old versions...');
11+
12+
const packageJsonPath = join(cwd, 'package.json');
13+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
14+
15+
if (!packageJson.resolutions) packageJson.resolutions = {};
16+
packageJson.resolutions['@types/express'] = '4.17.13';
17+
packageJson.resolutions['@types/express-serve-static-core'] = '4.17.30';
18+
19+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
20+
21+
const tsVersion = '3.8';
22+
23+
console.log(`Installing typescript@${tsVersion}, and @types/node@14...`);
24+
25+
execSync(`yarn add --dev --ignore-workspace-root-check typescript@${tsVersion} @types/node@^14`, {
26+
stdio: 'inherit',
27+
cwd,
28+
});
29+
30+
console.log('Removing unsupported tsconfig options...');
31+
32+
const baseTscConfigPath = join(cwd, 'packages/typescript/tsconfig.json');
33+
34+
const tsConfig = require(baseTscConfigPath);
35+
36+
// TS 3.8 fails build when it encounters a config option it does not understand, so we remove it :(
37+
delete tsConfig.compilerOptions.noUncheckedIndexedAccess;
38+
39+
writeFileSync(baseTscConfigPath, JSON.stringify(tsConfig, null, 2));

dev-packages/node-integration-tests/scripts/use-ts-version.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/nestjs/src/setup.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import { isExpectedError } from './helpers';
2727
// https://github.com/fastify/fastify/blob/87f9f20687c938828f1138f91682d568d2a31e53/types/request.d.ts#L41
2828
interface FastifyRequest {
2929
routeOptions?: {
30-
method?: string;
3130
url?: string;
3231
};
32+
method?: string;
3333
}
3434

3535
// Partial extract of ExpressRequest interface
@@ -72,9 +72,7 @@ class SentryTracingInterceptor implements NestInterceptor {
7272
const req = context.switchToHttp().getRequest() as FastifyRequest | ExpressRequest;
7373
if ('routeOptions' in req && req.routeOptions && req.routeOptions.url) {
7474
// fastify case
75-
getIsolationScope().setTransactionName(
76-
`${(req.routeOptions.method || 'GET').toUpperCase()} ${req.routeOptions.url}`,
77-
);
75+
getIsolationScope().setTransactionName(`${(req.method || 'GET').toUpperCase()} ${req.routeOptions.url}`);
7876
} else if ('route' in req && req.route && req.route.path) {
7977
// express case
8078
getIsolationScope().setTransactionName(`${(req.method || 'GET').toUpperCase()} ${req.route.path}`);

packages/node/src/integrations/tracing/fastify.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ interface Fastify {
2525
* Works for Fastify 3, 4 and presumably 5.
2626
*/
2727
interface FastifyRequestRouteInfo {
28+
method?: string;
2829
2930
routeOptions?: {
3031
url?: string;
31-
method?: string;
3232
};
3333
routerPath?: string;
3434
}
@@ -107,7 +107,7 @@ export function setupFastifyErrorHandler(fastify: Fastify): void {
107107
// Taken from Otel Fastify instrumentation:
108108
// https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts#L94-L96
109109
const routeName = reqWithRouteInfo.routeOptions?.url || reqWithRouteInfo.routerPath;
110-
const method = reqWithRouteInfo.routeOptions?.method || 'GET';
110+
const method = reqWithRouteInfo.method || 'GET';
111111

112112
getIsolationScope().setTransactionName(`${method} ${routeName}`);
113113
});

packages/node/src/integrations/tracing/nest/nest.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ export function setupNestErrorHandler(app: MinimalNestJsApp, baseFilter: NestJsE
9191
const req = context.switchToHttp().getRequest();
9292
if ('routeOptions' in req && req.routeOptions && req.routeOptions.url) {
9393
// fastify case
94-
getIsolationScope().setTransactionName(
95-
`${req.routeOptions.method?.toUpperCase() || 'GET'} ${req.routeOptions.url}`,
96-
);
94+
getIsolationScope().setTransactionName(`${req.method?.toUpperCase() || 'GET'} ${req.routeOptions.url}`);
9795
} else if ('route' in req && req.route && req.route.path) {
9896
// express case
9997
getIsolationScope().setTransactionName(`${req.method?.toUpperCase() || 'GET'} ${req.route.path}`);

packages/node/src/integrations/tracing/nest/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// https://github.com/fastify/fastify/blob/87f9f20687c938828f1138f91682d568d2a31e53/types/request.d.ts#L41
55
interface FastifyRequest {
66
routeOptions?: {
7-
method?: string;
87
url?: string;
98
};
9+
method?: string;
1010
}
1111

1212
// Partial extract of ExpressRequest interface

0 commit comments

Comments
 (0)