File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
dev-packages/e2e-tests/test-applications/nextjs-13/tests/server
packages/nextjs/src/server Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { test } from '@playwright/test' ;
2
+ import { waitForTransaction } from '@sentry-internal/test-utils' ;
3
+
4
+ test ( 'should create a transaction for a CJS pages router API endpoint' , async ( { page } ) => {
5
+ let received404Transaction = false ;
6
+ waitForTransaction ( 'nextjs-13' , async transactionEvent => {
7
+ return transactionEvent . transaction === 'GET /404' || transactionEvent . transaction === 'GET /_not-found' ;
8
+ } ) . then ( ( ) => {
9
+ received404Transaction = true ;
10
+ } ) ;
11
+
12
+ await page . goto ( '/page-that-doesnt-exist' ) ;
13
+
14
+ await new Promise < void > ( ( resolve , reject ) => {
15
+ setTimeout ( ( ) => {
16
+ if ( received404Transaction ) {
17
+ reject ( new Error ( 'received 404 transaction' ) ) ;
18
+ } else {
19
+ resolve ( ) ;
20
+ }
21
+ } , 5_000 ) ;
22
+ } ) ;
23
+ } ) ;
Original file line number Diff line number Diff line change @@ -219,8 +219,14 @@ export function init(options: NodeOptions): NodeClient | undefined {
219
219
return null ;
220
220
}
221
221
222
- // Filter out /404 transactions for pages-router which seem to be created excessively
223
- if ( event . transaction === '/404' ) {
222
+ // Filter out /404 transactions which seem to be created excessively
223
+ if (
224
+ // Pages router
225
+ event . transaction === '/404' ||
226
+ // App router (could be "GET /404", "POST /404", ...)
227
+ event . transaction ?. match ( / ^ ( G E T | H E A D | P O S T | P U T | D E L E T E | C O N N E C T | O P T I O N S | T R A C E | P A T C H ) \/ 4 0 4 $ / ) ||
228
+ event . transaction === 'GET /_not-found'
229
+ ) {
224
230
return null ;
225
231
}
226
232
You can’t perform that action at this time.
0 commit comments