Repository navigation
test(e2e): Run fastify-5 on Bun and Deno #26828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+273
−113
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "imports": { | ||
| "@sentry/deno/import": "./node_modules/@sentry/deno/build/import.mjs" | ||
| }, | ||
| "nodeModulesDir": "manual", | ||
| "unstable": ["sloppy-imports"] | ||
| } |
41 changes: 41 additions & 0 deletions
41
dev-packages/e2e-tests/test-applications/fastify-5/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "name": "fastify-5", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "start": "node dist/main.js", | ||
| "start:bun": "bun dist/main.js", | ||
| "start:deno": "deno run -A --preload=@sentry/deno/import --preload=./src/instrument.ts src/main.ts", | ||
| "test": "playwright test", | ||
| "clean": "npx rimraf node_modules pnpm-lock.yaml", | ||
| "test:build": "pnpm install && pnpm build", | ||
| "test:assert": "pnpm test" | ||
| }, | ||
| "dependencies": { | ||
| "@sentry/bun": "file:../../packed/sentry-bun-packed.tgz", | ||
| "@sentry/deno": "file:../../packed/sentry-deno-packed.tgz", | ||
| "@sentry/node": "file:../../packed/sentry-node-packed.tgz", | ||
| "@types/node": "^18.19.1", | ||
| "fastify": "^5.7.0", | ||
| "typescript": "5.6.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "1.64.1", | ||
| "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz", | ||
| "@sentry/core": "file:../../packed/sentry-core-packed.tgz" | ||
| }, | ||
| "sentryTest": { | ||
| "optionalVariants": [ | ||
| { | ||
| "runtime": "bun", | ||
| "bun-version": "1.4.5", | ||
| "label": "fastify-5 (bun)" | ||
| }, | ||
|
Check warning on line 34 in dev-packages/e2e-tests/test-applications/fastify-5/package.json
|
||
| { | ||
| "runtime": "deno", | ||
| "label": "fastify-5 (deno)" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
dev-packages/e2e-tests/test-applications/fastify-5/playwright.config.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils'; | ||
|
|
||
| const startCommands = { | ||
| node: 'pnpm start', | ||
| bun: 'pnpm start:bun', | ||
| deno: 'pnpm start:deno', | ||
| }; | ||
|
|
||
| const config = getPlaywrightConfig({ | ||
| startCommand: startCommands[getRuntime()], | ||
| }); | ||
|
|
||
| export default config; |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
dev-packages/e2e-tests/test-applications/fastify-5/src/instrument.bun.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import * as Sentry from '@sentry/bun'; | ||
| import { shouldHandleError } from './shouldHandleError'; | ||
|
|
||
| Sentry.init({ | ||
| environment: 'qa', // dynamic sampling bias to keep transactions | ||
| dsn: process.env.E2E_TEST_DSN, | ||
| integrations: [Sentry.fastifyIntegration({ shouldHandleError })], | ||
| tracesSampleRate: 1, | ||
| tunnel: 'http://localhost:3031/', // proxy server | ||
| tracePropagationTargets: ['http://localhost:3030', '/external-allowed'], | ||
| }); |
11 changes: 11 additions & 0 deletions
11
dev-packages/e2e-tests/test-applications/fastify-5/src/instrument.deno.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import * as Sentry from '@sentry/deno'; | ||
| import { shouldHandleError } from './shouldHandleError'; | ||
|
|
||
| Sentry.init({ | ||
| environment: 'qa', // dynamic sampling bias to keep transactions | ||
| dsn: process.env.E2E_TEST_DSN, | ||
| integrations: [Sentry.fastifyIntegration({ shouldHandleError })], | ||
| tracesSampleRate: 1, | ||
| tunnel: 'http://localhost:3031/', // proxy server | ||
| tracePropagationTargets: ['http://localhost:3030', '/external-allowed'], | ||
| }); |
24 changes: 24 additions & 0 deletions
24
dev-packages/e2e-tests/test-applications/fastify-5/src/instrument.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import * as Sentry from '@sentry/node'; | ||
| import { shouldHandleError } from './shouldHandleError'; | ||
|
|
||
| // We wrap console.warn to find out if a warning is incorrectly logged | ||
| console.warn = new Proxy(console.warn, { | ||
| apply: function (target, thisArg, argumentsList) { | ||
| const msg = argumentsList[0]; | ||
| if (typeof msg === 'string' && msg.startsWith('[Sentry]')) { | ||
| console.error(`Sentry warning was triggered: ${msg}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| return target.apply(thisArg, argumentsList); | ||
| }, | ||
| }); | ||
|
|
||
| Sentry.init({ | ||
| environment: 'qa', // dynamic sampling bias to keep transactions | ||
| dsn: process.env.E2E_TEST_DSN, | ||
| integrations: [Sentry.fastifyIntegration({ shouldHandleError })], | ||
| tracesSampleRate: 1, | ||
| tunnel: 'http://localhost:3031/', // proxy server | ||
| tracePropagationTargets: ['http://localhost:3030', '/external-allowed'], | ||
| }); |
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/fastify-5/src/main.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import './instrument'; | ||
|
|
||
| import { app, app2 } from './app'; | ||
|
|
||
| app.listen({ port: 3030 }); | ||
| app2.listen({ port: 3040 }); |
1 change: 1 addition & 0 deletions
1
dev-packages/e2e-tests/test-applications/fastify-5/src/sentry.bun.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from '@sentry/bun'; |
1 change: 1 addition & 0 deletions
1
dev-packages/e2e-tests/test-applications/fastify-5/src/sentry.deno.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from '@sentry/deno'; |
2 changes: 2 additions & 0 deletions
2
dev-packages/e2e-tests/test-applications/fastify-5/src/sentry.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // The app imports the Sentry API from this file. Each other runtime has a `sentry.<runtime>.ts` with its own SDK. | ||
| export * from '@sentry/node'; |
15 changes: 15 additions & 0 deletions
15
dev-packages/e2e-tests/test-applications/fastify-5/src/shouldHandleError.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type { fastifyIntegration } from './sentry'; | ||
|
|
||
| type ShouldHandleError = NonNullable<NonNullable<Parameters<typeof fastifyIntegration>[0]>['shouldHandleError']>; | ||
|
|
||
| export const shouldHandleError: ShouldHandleError = (_error, request, reply) => { | ||
| if (request.routeOptions?.url?.includes('/test-error-not-captured')) { | ||
| return false; | ||
| } | ||
|
|
||
| if (request.routeOptions?.url?.includes('/test-error-ignored') && reply.statusCode === 500) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
dev-packages/e2e-tests/test-applications/fastify-5/tests/constants.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { getRuntime } from '@sentry-internal/test-utils'; | ||
|
|
||
| export const RUNTIME = getRuntime(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
dev-packages/e2e-tests/test-applications/fastify-5/tests/logs.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { collectStreamedSpansUntilSegment, waitForEnvelopeItem } from '@sentry-internal/test-utils'; | ||
| import type { SerializedLogContainer } from '@sentry/core'; | ||
|
|
||
| test('Sends logs with the trace of the request', async ({ baseURL }) => { | ||
| const logEnvelopePromise = waitForEnvelopeItem('fastify-5', envelope => { | ||
| return envelope[0].type === 'log' && (envelope[1] as SerializedLogContainer).items[0]?.level === 'debug'; | ||
| }); | ||
| const spansPromise = collectStreamedSpansUntilSegment('fastify-5', 'GET /test-log'); | ||
|
|
||
| await fetch(`${baseURL}/test-log`); | ||
|
|
||
| const logEnvelope = await logEnvelopePromise; | ||
| const log = (logEnvelope[1] as SerializedLogContainer).items[0]; | ||
| expect(log?.level).toBe('debug'); | ||
| expect(log?.body).toBe('Accessed /test-log route'); | ||
|
|
||
| const segmentSpan = (await spansPromise).find(span => span.is_segment)!; | ||
| expect(log?.trace_id).toBe(segmentSpan.trace_id); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bun optional variant fails on http.response.status_text assertions
Enabling the bun optional variant will fail spans/propagation tests that require
http.response.status_text: OK. Bun leavesstatusMessageunset onnode:httpresponses; gate that attribute withRUNTIME === 'bun'like express-5 and nestjs-12.Evidence
optionalVariantsaddsruntime: "bun"(withstart:bun→bun dist/main.js), so CI runs the existing Playwright suite under Bun.http.response.status_textonly fromresponse.statusMessage?.toUpperCase()(packages/core/src/integrations/http/server-subscription.ts).statusMessageunset and omit the attribute whenRUNTIME === 'bun'.tests/spans.test.tsandtests/propagation.test.tsstill require'http.response.status_text': { value: 'OK', type: 'string' }with no Bun branch, so those expects fail under the new variant.Identified by Warden · code-review · L8N-WT2