Skip to content

Commit bb85aa2

Browse files
committed
fix weird ./../../ prefix
1 parent d0f6b28 commit bb85aa2

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

packages/next/src/server/lib/router-utils/setup-dev-bundler.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1180,12 +1180,8 @@ async function traceTurbopackErrorStack(
11801180

11811181
if (f.file != null) {
11821182
const file =
1183-
f.file.startsWith('/') ||
11841183
// Built-in "filenames" like `<anonymous>` shouldn't be made relative
1185-
f.file.startsWith('<') ||
1186-
f.file.startsWith('node:')
1187-
? f.file
1188-
: `./${f.file}`
1184+
/^(\/|\.\.\/|\.\/|<|node:)/.test(f.file) ? f.file : `./${f.file}`
11891185

11901186
line += ` (${file}`
11911187
if (f.lineNumber != null) {

test/integration/server-side-dev-errors/test/index.test.js

+13-19
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ describe('server-side dev errors', () => {
7272
)
7373
expect(stderrOutput).toContain(
7474
' ⨯ ReferenceError: missingVar is not defined' +
75-
// TODO(sokra) weird ./ in front of the ../../
76-
'\n at getStaticProps (./../../test/integration/server-side-dev-errors/pages/gsp.js:6:3)' +
75+
'\n at getStaticProps (../../test/integration/server-side-dev-errors/pages/gsp.js:6:3)' +
7776
// TODO(veil): Should be sourcemapped
7877
'\n at'
7978
)
@@ -126,8 +125,7 @@ describe('server-side dev errors', () => {
126125
)
127126
expect(stderrOutput).toContain(
128127
' ⨯ ReferenceError: missingVar is not defined' +
129-
// TODO(sokra) weird ./ in front of the ../../
130-
'\n at getServerSideProps (./../../test/integration/server-side-dev-errors/pages/gssp.js:6:3)' +
128+
'\n at getServerSideProps (../../test/integration/server-side-dev-errors/pages/gssp.js:6:3)' +
131129
// TODO(veil): Should be sourcemapped
132130
'\n at'
133131
)
@@ -180,8 +178,7 @@ describe('server-side dev errors', () => {
180178
)
181179
expect(stderrOutput).toContain(
182180
' ⨯ ReferenceError: missingVar is not defined' +
183-
// TODO(sokra) weird ./ in front of the ../../
184-
'\n at getServerSideProps (./../../test/integration/server-side-dev-errors/pages/blog/[slug].js:6:3)' +
181+
'\n at getServerSideProps (../../test/integration/server-side-dev-errors/pages/blog/[slug].js:6:3)' +
185182
// TODO(veil): Should be sourcemapped
186183
'\n at'
187184
)
@@ -235,8 +232,7 @@ describe('server-side dev errors', () => {
235232
// TODO(sokra) Error should be ReferenceError. Why isn't it?
236233
expect(stderrOutput).toContain(
237234
' ⨯ Error: missingVar is not defined' +
238-
// TODO(sokra) weird ./ in front of the ../../
239-
'\n at handler (./../../test/integration/server-side-dev-errors/pages/api/hello.js:2:3)' +
235+
'\n at handler (../../test/integration/server-side-dev-errors/pages/api/hello.js:2:3)' +
240236
// TODO(veil): Should be sourcemapped
241237
'\n at'
242238
)
@@ -291,8 +287,7 @@ describe('server-side dev errors', () => {
291287
)
292288
expect(stderrOutput).toContain(
293289
'\n ⨯ ReferenceError: missingVar is not defined' +
294-
// TODO(sokra) weird ./ in front of the ../../
295-
'\n at handler (./../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js:2:3)' +
290+
'\n at handler (../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js:2:3)' +
296291
// TODO(veil): Should be sourcemapped
297292
'\n at'
298293
)
@@ -334,7 +329,6 @@ describe('server-side dev errors', () => {
334329
// FIXME(veil): codeframe repeated after " ⨯ unhandledRejection: Error: catch this rejection"
335330
if (isTurbopack) {
336331
// TODO(veil): digest: undefined should be omitted?
337-
// TODO(sokra) weird ./ in front of the ../../
338332
expect(stderrOutput).toMatchInlineSnapshot(`
339333
"Error: catch this rejection
340334
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-rejection.js:7:19)
@@ -348,7 +342,7 @@ describe('server-side dev errors', () => {
348342
⨯ ../../test/integration/server-side-dev-errors/pages/uncaught-rejection.js (7:20) @ Timeout._onTimeout
349343
⨯ ../../test/integration/server-side-dev-errors/pages/uncaught-rejection.js (7:20) @ Timeout._onTimeout
350344
⨯ unhandledRejection: Error: catch this rejection
351-
at Timeout._onTimeout (./../../test/integration/server-side-dev-errors/pages/uncaught-rejection.js:7:20) {
345+
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-rejection.js:7:20) {
352346
digest: undefined
353347
}
354348
5 | export async function getServerSideProps() {
@@ -359,7 +353,7 @@ describe('server-side dev errors', () => {
359353
9 | return {
360354
10 | props: {},
361355
⨯ unhandledRejection: Error: catch this rejection
362-
at Timeout._onTimeout (./../../test/integration/server-side-dev-errors/pages/uncaught-rejection.js:7:20) {
356+
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-rejection.js:7:20) {
363357
digest: undefined
364358
}
365359
5 | export async function getServerSideProps() {
@@ -448,7 +442,7 @@ describe('server-side dev errors', () => {
448442
⨯ ../../test/integration/server-side-dev-errors/pages/uncaught-empty-rejection.js (7:20) @ Timeout._onTimeout
449443
⨯ ../../test/integration/server-side-dev-errors/pages/uncaught-empty-rejection.js (7:20) @ Timeout._onTimeout
450444
⨯ unhandledRejection: Error:
451-
at Timeout._onTimeout (./../../test/integration/server-side-dev-errors/pages/uncaught-empty-rejection.js:7:20) {
445+
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-empty-rejection.js:7:20) {
452446
digest: undefined
453447
}
454448
5 | export async function getServerSideProps() {
@@ -459,7 +453,7 @@ describe('server-side dev errors', () => {
459453
9 | return {
460454
10 | props: {},
461455
⨯ unhandledRejection: Error:
462-
at Timeout._onTimeout (./../../test/integration/server-side-dev-errors/pages/uncaught-empty-rejection.js:7:20) {
456+
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-empty-rejection.js:7:20) {
463457
digest: undefined
464458
}
465459
5 | export async function getServerSideProps() {
@@ -547,7 +541,7 @@ describe('server-side dev errors', () => {
547541
⨯ ../../test/integration/server-side-dev-errors/pages/uncaught-exception.js (7:11) @ Timeout._onTimeout
548542
⨯ ../../test/integration/server-side-dev-errors/pages/uncaught-exception.js (7:11) @ Timeout._onTimeout
549543
⨯ uncaughtException: Error: catch this exception
550-
at Timeout._onTimeout (./../../test/integration/server-side-dev-errors/pages/uncaught-exception.js:7:11) {
544+
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-exception.js:7:11) {
551545
digest: undefined
552546
}
553547
5 | export async function getServerSideProps() {
@@ -558,7 +552,7 @@ describe('server-side dev errors', () => {
558552
9 | return {
559553
10 | props: {},
560554
⨯ uncaughtException: Error: catch this exception
561-
at Timeout._onTimeout (./../../test/integration/server-side-dev-errors/pages/uncaught-exception.js:7:11) {
555+
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-exception.js:7:11) {
562556
digest: undefined
563557
}
564558
5 | export async function getServerSideProps() {
@@ -646,7 +640,7 @@ describe('server-side dev errors', () => {
646640
⨯ ../../test/integration/server-side-dev-errors/pages/uncaught-empty-exception.js (7:11) @ Timeout._onTimeout
647641
⨯ ../../test/integration/server-side-dev-errors/pages/uncaught-empty-exception.js (7:11) @ Timeout._onTimeout
648642
⨯ uncaughtException: Error:
649-
at Timeout._onTimeout (./../../test/integration/server-side-dev-errors/pages/uncaught-empty-exception.js:7:11) {
643+
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-empty-exception.js:7:11) {
650644
digest: undefined
651645
}
652646
5 | export async function getServerSideProps() {
@@ -657,7 +651,7 @@ describe('server-side dev errors', () => {
657651
9 | return {
658652
10 | props: {},
659653
⨯ uncaughtException: Error:
660-
at Timeout._onTimeout (./../../test/integration/server-side-dev-errors/pages/uncaught-empty-exception.js:7:11) {
654+
at Timeout._onTimeout (../../test/integration/server-side-dev-errors/pages/uncaught-empty-exception.js:7:11) {
661655
digest: undefined
662656
}
663657
5 | export async function getServerSideProps() {

0 commit comments

Comments
 (0)