File tree Expand file tree Collapse file tree 2 files changed +34
-13
lines changed Expand file tree Collapse file tree 2 files changed +34
-13
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ import {
2020 resolveDynamicComponent ,
2121 renderSlot ,
2222 onErrorCaptured ,
23- onServerPrefetch
23+ onServerPrefetch ,
24+ getCurrentInstance
2425} from 'vue'
2526import { escapeHtml } from '@vue/shared'
2627import { renderToString } from '../src/renderToString'
@@ -779,6 +780,23 @@ function testRender(type: string, render: typeof renderToString) {
779780 ) . toHaveBeenWarned ( )
780781 expect ( `Element is missing end tag` ) . toHaveBeenWarned ( )
781782 } )
783+
784+ // #6110
785+ test ( 'reset current instance after rendering error' , async ( ) => {
786+ const prev = getCurrentInstance ( )
787+ expect ( prev ) . toBe ( null )
788+ try {
789+ await render (
790+ createApp ( {
791+ data ( ) {
792+ return { msg : null }
793+ } ,
794+ template : `<div>{{ msg.text }}</div>`
795+ } )
796+ )
797+ } catch { }
798+ expect ( getCurrentInstance ( ) ) . toBe ( prev )
799+ } )
782800 } )
783801
784802 test ( 'serverPrefetch' , async ( ) => {
Original file line number Diff line number Diff line change @@ -174,18 +174,21 @@ function renderComponentSubTree(
174174
175175 // set current rendering instance for asset resolution
176176 const prev = setCurrentRenderingInstance ( instance )
177- ssrRender (
178- instance . proxy ,
179- push ,
180- instance ,
181- attrs ,
182- // compiler-optimized bindings
183- instance . props ,
184- instance . setupState ,
185- instance . data ,
186- instance . ctx
187- )
188- setCurrentRenderingInstance ( prev )
177+ try {
178+ ssrRender (
179+ instance . proxy ,
180+ push ,
181+ instance ,
182+ attrs ,
183+ // compiler-optimized bindings
184+ instance . props ,
185+ instance . setupState ,
186+ instance . data ,
187+ instance . ctx
188+ )
189+ } finally {
190+ setCurrentRenderingInstance ( prev )
191+ }
189192 } else if ( instance . render && instance . render !== NOOP ) {
190193 renderVNode (
191194 push ,
You can’t perform that action at this time.
0 commit comments