@@ -12,6 +12,7 @@ import {
12
12
defineComponent ,
13
13
getCurrentInstance ,
14
14
h ,
15
+ nextTick ,
15
16
onErrorCaptured ,
16
17
onServerPrefetch ,
17
18
reactive ,
@@ -819,6 +820,9 @@ function testRender(type: string, render: typeof renderToString) {
819
820
)
820
821
} catch { }
821
822
expect ( getCurrentInstance ( ) ) . toBe ( prev )
823
+ expect (
824
+ '[Vue warn]: Unhandled error during execution of render function' ,
825
+ ) . toHaveBeenWarned ( )
822
826
} )
823
827
824
828
// #7733
@@ -1188,6 +1192,42 @@ function testRender(type: string, render: typeof renderToString) {
1188
1192
expect ( ( capturedError as unknown as Error ) . message ) . toBe ( 'An error' )
1189
1193
} )
1190
1194
1195
+ test ( 'async setup throwing error' , async ( ) => {
1196
+ let capturedError : string [ ] = [ ]
1197
+
1198
+ const Child = {
1199
+ async setup ( ) {
1200
+ await nextTick ( )
1201
+ throw new Error ( 'An error' )
1202
+ return { foo : { bar : 1 } }
1203
+ } ,
1204
+ template : `<span>{{ foo.bar }}</span>` ,
1205
+ }
1206
+
1207
+ const app = createApp ( {
1208
+ components : { Child } ,
1209
+ setup ( ) {
1210
+ onErrorCaptured ( e => {
1211
+ capturedError . push ( e . message )
1212
+ return false
1213
+ } )
1214
+ } ,
1215
+ template : `<Suspense><Child /></Suspense>` ,
1216
+ } )
1217
+
1218
+ try {
1219
+ await render ( app )
1220
+ } catch ( e : any ) { }
1221
+ expect ( capturedError . length ) . toBe ( 2 )
1222
+ expect ( capturedError ) . toStrictEqual ( [
1223
+ 'An error' ,
1224
+ "Cannot read properties of undefined (reading 'bar')" ,
1225
+ ] )
1226
+ expect (
1227
+ '[Vue warn]: Property "foo" was accessed during render but is not defined on instance' ,
1228
+ ) . toHaveBeenWarned ( )
1229
+ } )
1230
+
1191
1231
test ( 'computed reactivity during SSR with onServerPrefetch' , async ( ) => {
1192
1232
const store = {
1193
1233
// initial state could be hydrated
0 commit comments