File size: 4,419 Bytes
94786da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
diff --git a/test/development/app-dir/special-project-paths/fixtures/app/layout.js b/test/development/app-dir/special-project-paths/fixtures/app/layout.js
new file mode 100644
index 0000000000000000000000000000000000000000..803f17d863c8ad887c14588aab3487e473367b41
--- /dev/null
+++ b/test/development/app-dir/special-project-paths/fixtures/app/layout.js
@@ -0,0 +1,7 @@
+export default function RootLayout({ children }) {
+  return (
+    <html>
+      <body>{children}</body>
+    </html>
+  )
+}
diff --git a/test/development/app-dir/special-project-paths/fixtures/app/ssr-throw/Thrower.js b/test/development/app-dir/special-project-paths/fixtures/app/ssr-throw/Thrower.js
new file mode 100644
index 0000000000000000000000000000000000000000..140fa61e8ba3c0d722afbabe5ba1d69de79bf0f2
--- /dev/null
+++ b/test/development/app-dir/special-project-paths/fixtures/app/ssr-throw/Thrower.js
@@ -0,0 +1,10 @@
+'use client'
+
+function throwError() {
+  throw new Error('ssr-throw')
+}
+
+export function Thrower() {
+  throwError()
+  return null
+}
diff --git a/test/development/app-dir/special-project-paths/fixtures/app/ssr-throw/page.js b/test/development/app-dir/special-project-paths/fixtures/app/ssr-throw/page.js
new file mode 100644
index 0000000000000000000000000000000000000000..d5d6f5cad684f2e81f3c796e9a7e0ede72c95637
--- /dev/null
+++ b/test/development/app-dir/special-project-paths/fixtures/app/ssr-throw/page.js
@@ -0,0 +1,5 @@
+import { Thrower } from './Thrower'
+
+export default function Page() {
+  return <Thrower />
+}
diff --git a/test/development/app-dir/special-project-paths/fixtures/next.config.js b/test/development/app-dir/special-project-paths/fixtures/next.config.js
new file mode 100644
index 0000000000000000000000000000000000000000..4ba52ba2c8df6758685c8f65f490306b5c44eb76
--- /dev/null
+++ b/test/development/app-dir/special-project-paths/fixtures/next.config.js
@@ -0,0 +1 @@
+module.exports = {}
diff --git a/test/development/app-dir/special-project-paths/special-project-paths.test.ts b/test/development/app-dir/special-project-paths/special-project-paths.test.ts
new file mode 100644
index 0000000000000000000000000000000000000000..4f5399aff3c8c153fa06a243c81ad8ea6c6ff89d
--- /dev/null
+++ b/test/development/app-dir/special-project-paths/special-project-paths.test.ts
@@ -0,0 +1,66 @@
+import * as path from 'path'
+import { nextTestSetup } from 'e2e-utils'
+import stripAnsi from 'strip-ansi'
+import { getRedboxSource, retry } from 'next-test-utils'
+
+function setup(subDir: string) {
+  return nextTestSetup({
+    files: path.join(__dirname, 'fixtures'),
+    subDir,
+  })
+}
+
+async function assertSymbolicatedSSRError(
+  next: ReturnType<typeof setup>['next']
+) {
+  const outputIndex = next.cliOutput.length
+  const browser = await next.browser('/ssr-throw')
+
+  await retry(() => {
+    expect(next.cliOutput.slice(outputIndex)).toContain('Error: ssr-throw')
+  })
+
+  const cliOutput = stripAnsi(next.cliOutput.slice(outputIndex))
+  expect(cliOutput).toContain('at throwError (app/ssr-throw/Thrower.js:4:9)')
+  expect(cliOutput).toContain('at Thrower (app/ssr-throw/Thrower.js:8:3)')
+  expect(cliOutput).toContain("throw new Error('ssr-throw')")
+
+  let redboxSource: string | null = null
+  await retry(async () => {
+    redboxSource = await getRedboxSource(browser)
+    expect(redboxSource).not.toBeNull()
+  })
+  expect(redboxSource).toContain('app/ssr-throw/Thrower.js (4:9) @ throwError')
+  expect(redboxSource).toContain("throw new Error('ssr-throw')")
+}
+
+// Symbolication must work in project directories whose absolute path
+// contains characters that need percent-encoding in URLs.
+describe('special project paths', () => {
+  describe('in "space dir"', () => {
+    const { skipped, next } = setup('space dir')
+    if (skipped) return
+
+    it('symbolicates thrown SSR errors', async () => {
+      await assertSymbolicatedSSRError(next)
+    })
+  })
+
+  describe('in "ünïcode-dir"', () => {
+    const { skipped, next } = setup('ünïcode-dir')
+    if (skipped) return
+
+    it('symbolicates thrown SSR errors', async () => {
+      await assertSymbolicatedSSRError(next)
+    })
+  })
+
+  describe('in "bracket [dir]"', () => {
+    const { skipped, next } = setup('bracket [dir]')
+    if (skipped) return
+
+    it('symbolicates thrown SSR errors', async () => {
+      await assertSymbolicatedSSRError(next)
+    })
+  })
+})