Skip to content

Commit

Permalink
Merge pull request #13249 from getsentry/prepare-release/8.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome authored Aug 6, 2024
2 parents 62271a1 + 7c7e2e2 commit d73daeb
Show file tree
Hide file tree
Showing 35 changed files with 410 additions and 319 deletions.
28 changes: 28 additions & 0 deletions .github/actions/install-playwright/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Install Playwright dependencies"
description: "Installs Playwright dependencies and caches them."

runs:
using: "composite"
steps:
- name: Get Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
shell: bash

- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}

- name: Install Playwright dependencies (uncached)
run: npx playwright install chromium webkit firefox --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash

- name: Install Playwright system dependencies only (cached)
run: npx playwright install-deps chromium webkit firefox
if: steps.playwright-cache.outputs.cache-hit == 'true'
shell: bash
261 changes: 84 additions & 177 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

22 changes: 2 additions & 20 deletions .github/workflows/flaky-test-detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,8 @@ jobs:
- name: Build packages
run: yarn build

- name: Get npm cache directory
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Get Playwright version
id: playwright-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Check if Playwright browser is cached
id: playwright-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
- name: Install Playwright browser if not cached
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
env:
PLAYWRIGHT_BROWSERS_PATH: ${{steps.npm-cache-dir.outputs.dir}}
- name: Install OS dependencies of Playwright if cache hit
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps
- name: Install Playwright
uses: ./.github/actions/install-playwright

- name: Determine changed tests
uses: dorny/paths-filter@v3.0.1
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott

## 8.24.0

- feat(nestjs): Filter RPC exceptions (#13227)
- fix: Guard getReader function for other fetch implementations (#13246)
- fix(feedback): Ensure feedback can be lazy loaded in CDN bundles (#13241)

## 8.23.0

### Important Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Sentry from '@sentry/browser';

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [],
});

window.Sentry = {
...Sentry,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
window._testLazyLoadIntegration = async function run() {
const integration = await window.Sentry.lazyLoadIntegration('feedbackIntegration');

window.Sentry.getClient()?.addIntegration(integration());

window._integrationLoaded = true;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { expect } from '@playwright/test';
import { SDK_VERSION } from '@sentry/browser';

import { sentryTest } from '../../../../utils/fixtures';

sentryTest('it allows to lazy load the feedback integration', async ({ getLocalTestUrl, page }) => {
const bundle = process.env.PW_BUNDLE || '';
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route(`https://browser.sentry-cdn.com/${SDK_VERSION}/feedback.min.js`, route => {
return route.fulfill({
status: 200,
contentType: 'application/javascript;',
body: "window.Sentry.feedbackIntegration = () => ({ name: 'Feedback', attachTo: () => {} })",
});
});

await page.goto(url);

await page.waitForFunction('window.Sentry?.getClient()');

const integrationOutput1 = await page.evaluate('window.Sentry.feedbackIntegration?._isShim');

// Multiple cases are possible here:
// 1. Bundle without feedback, should have _isShim property
if (bundle.startsWith('bundle') && !bundle.includes('feedback')) {
expect(integrationOutput1).toBe(true);
} else {
// 2. Either bundle with feedback, or ESM, should not have _isShim property
expect(integrationOutput1).toBe(undefined);
}

await page.evaluate('window._testLazyLoadIntegration()');
await page.waitForFunction('window._integrationLoaded');

const integrationOutput2 = await page.evaluate('window.Sentry.feedbackIntegration?._isShim');
expect(integrationOutput2).toBe(undefined);
});
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/Dockerfile.publish-packages
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ ARG NODE_VERSION=18.18.0
FROM node:${NODE_VERSION}

WORKDIR /sentry-javascript/dev-packages/e2e-tests
CMD [ "yarn", "ts-node", "publish-packages.ts" ]
CMD [ "yarn", "ts-node", "publish-packages.ts", "--transpile-only" ]
23 changes: 18 additions & 5 deletions dev-packages/e2e-tests/publish-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,22 @@ const packageTarballPaths = glob.sync('packages/*/sentry-*.tgz', {
// Publish built packages to the fake registry
packageTarballPaths.forEach(tarballPath => {
// `--userconfig` flag needs to be before `publish`
childProcess.execSync(`npm --userconfig ${__dirname}/test-registry.npmrc publish ${tarballPath}`, {
cwd: repositoryRoot, // Can't use __dirname here because npm would try to publish `@sentry-internal/e2e-tests`
encoding: 'utf8',
stdio: 'inherit',
});
childProcess.exec(
`npm --userconfig ${__dirname}/test-registry.npmrc publish ${tarballPath}`,
{
cwd: repositoryRoot, // Can't use __dirname here because npm would try to publish `@sentry-internal/e2e-tests`
encoding: 'utf8',
},
(err, stdout, stderr) => {
// eslint-disable-next-line no-console
console.log(stdout);
// eslint-disable-next-line no-console
console.log(stderr);
if (err) {
// eslint-disable-next-line no-console
console.error(err);
process.exit(1);
}
},
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';
startEventProxyServer({
port: 3031,
proxyServerName: 'aws-serverless-esm',
forwardToSentry: false,
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/microservices": "^10.0.0",
"@nestjs/schedule": "^4.1.0",
"@nestjs/platform-express": "^10.0.0",
"@sentry/nestjs": "latest || *",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller, Get, Param, ParseIntPipe, UseGuards, UseInterceptors } from '@nestjs/common';
import { flush } from '@sentry/nestjs';
import { AppService } from './app.service';
import { ExampleGuard } from './example.guard';
import { ExampleInterceptor } from './example.interceptor';
Expand Down Expand Up @@ -49,6 +50,11 @@ export class AppController {
return this.appService.testExpected500Exception(id);
}

@Get('test-expected-rpc-exception/:id')
async testExpectedRpcException(@Param('id') id: string) {
return this.appService.testExpectedRpcException(id);
}

@Get('test-span-decorator-async')
async testSpanDecoratorAsync() {
return { result: await this.appService.testSpanDecoratorAsync() };
Expand All @@ -63,4 +69,9 @@ export class AppController {
async killTestCron() {
this.appService.killTestCron();
}

@Get('flush')
async flush() {
await flush();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { RpcException } from '@nestjs/microservices';
import { Cron, SchedulerRegistry } from '@nestjs/schedule';
import * as Sentry from '@sentry/nestjs';
import { SentryCron, SentryTraced } from '@sentry/nestjs';
Expand Down Expand Up @@ -38,6 +39,10 @@ export class AppService {
throw new HttpException(`This is an expected 500 exception with id ${id}`, HttpStatus.INTERNAL_SERVER_ERROR);
}

testExpectedRpcException(id: string) {
throw new RpcException(`This is an expected RPC exception with id ${id}`);
}

@SentryTraced('wait and return a string')
async wait() {
await new Promise(resolve => setTimeout(resolve, 500));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,32 @@ test('Does not send HttpExceptions to Sentry', async ({ baseURL }) => {
await transactionEventPromise400;
await transactionEventPromise500;

await new Promise(resolve => setTimeout(resolve, 10000));
(await fetch(`${baseURL}/flush`)).text();

expect(errorEventOccurred).toBe(false);
});

test('Does not send RpcExceptions to Sentry', async ({ baseURL }) => {
let errorEventOccurred = false;

waitForError('nestjs-basic', event => {
if (!event.type && event.exception?.values?.[0]?.value === 'This is an expected RPC exception with id 123') {
errorEventOccurred = true;
}

return event?.transaction === 'GET /test-expected-rpc-exception/:id';
});

const transactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
return transactionEvent?.transaction === 'GET /test-expected-rpc-exception/:id';
});

const response = await fetch(`${baseURL}/test-expected-rpc-exception/123`);
expect(response.status).toBe(500);

await transactionEventPromise;

(await fetch(`${baseURL}/flush`)).text();

expect(errorEventOccurred).toBe(false);
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller, Get, Param } from '@nestjs/common';
import { flush } from '@sentry/nestjs';
import { AppService } from './app.service';

@Controller()
Expand All @@ -14,4 +15,9 @@ export class AppController {
async testExpectedException(@Param('id') id: string) {
return this.appService.testExpectedException(id);
}

@Get('flush')
async flush() {
await flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ test('Does not send exception to Sentry if user-defined global exception filter

await transactionEventPromise;

await new Promise(resolve => setTimeout(resolve, 10000));
(await fetch(`${baseURL}/flush`)).text();

expect(errorEventOccurred).toBe(false);
});
Expand Down Expand Up @@ -111,7 +111,7 @@ test('Does not send exception to Sentry if user-defined local exception filter a

await transactionEventPromise;

await new Promise(resolve => setTimeout(resolve, 10000));
(await fetch(`${baseURL}/flush`)).text();

expect(errorEventOccurred).toBe(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/microservices": "^10.0.0",
"@nestjs/schedule": "^4.1.0",
"@nestjs/platform-express": "^10.0.0",
"@sentry/nestjs": "latest || *",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller, Get, Param, ParseIntPipe, UseGuards, UseInterceptors } from '@nestjs/common';
import { flush } from '@sentry/nestjs';
import { AppService } from './app.service';
import { ExampleGuard } from './example.guard';
import { ExampleInterceptor } from './example.interceptor';
Expand Down Expand Up @@ -49,6 +50,11 @@ export class AppController {
return this.appService.testExpected500Exception(id);
}

@Get('test-expected-rpc-exception/:id')
async testExpectedRpcException(@Param('id') id: string) {
return this.appService.testExpectedRpcException(id);
}

@Get('test-span-decorator-async')
async testSpanDecoratorAsync() {
return { result: await this.appService.testSpanDecoratorAsync() };
Expand All @@ -63,4 +69,9 @@ export class AppController {
async killTestCron() {
this.appService.killTestCron();
}

@Get('flush')
async flush() {
await flush();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { RpcException } from '@nestjs/microservices';
import { Cron, SchedulerRegistry } from '@nestjs/schedule';
import * as Sentry from '@sentry/nestjs';
import { SentryCron, SentryTraced } from '@sentry/nestjs';
Expand Down Expand Up @@ -38,6 +39,10 @@ export class AppService {
throw new HttpException(`This is an expected 500 exception with id ${id}`, HttpStatus.INTERNAL_SERVER_ERROR);
}

testExpectedRpcException(id: string) {
throw new RpcException(`This is an expected RPC exception with id ${id}`);
}

@SentryTraced('wait and return a string')
async wait() {
await new Promise(resolve => setTimeout(resolve, 500));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,32 @@ test('Does not send HttpExceptions to Sentry', async ({ baseURL }) => {
await transactionEventPromise400;
await transactionEventPromise500;

await new Promise(resolve => setTimeout(resolve, 10000));
(await fetch(`${baseURL}/flush`)).text();

expect(errorEventOccurred).toBe(false);
});

test('Does not send RpcExceptions to Sentry', async ({ baseURL }) => {
let errorEventOccurred = false;

waitForError('node-nestjs-basic', event => {
if (!event.type && event.exception?.values?.[0]?.value === 'This is an expected RPC exception with id 123') {
errorEventOccurred = true;
}

return event?.transaction === 'GET /test-expected-rpc-exception/:id';
});

const transactionEventPromise = waitForTransaction('node-nestjs-basic', transactionEvent => {
return transactionEvent?.transaction === 'GET /test-expected-rpc-exception/:id';
});

const response = await fetch(`${baseURL}/test-expected-rpc-exception/123`);
expect(response.status).toBe(500);

await transactionEventPromise;

(await fetch(`${baseURL}/flush`)).text();

expect(errorEventOccurred).toBe(false);
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@sentry/nuxt": "latest || *",
"nuxt": "3.11.2"
"nuxt": "3.12.4"
},
"devDependencies": {
"@nuxt/test-utils": "^3.13.1",
Expand Down
2 changes: 2 additions & 0 deletions dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"@nestjs/core": "^10.3.3",
"@nestjs/platform-express": "^10.3.3",
"@prisma/client": "5.9.1",
"@sentry/aws-serverless": "8.23.0",
"@sentry/node": "8.23.0",
"@sentry/utils": "8.23.0",
"@sentry/types": "8.23.0",
"@types/mongodb": "^3.6.20",
"@types/mysql": "^2.15.21",
Expand Down
Loading

0 comments on commit d73daeb

Please sign in to comment.