File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -670,5 +670,42 @@ describe('error handling', () => {
670670 )
671671 } )
672672
673+ // #11624
674+ test ( 'in computed that is used as key for watch' , async ( ) => {
675+ const err = new Error ( 'foo' )
676+ const fn = vi . fn ( )
677+ const trigger = ref ( false )
678+
679+ const Comp = {
680+ setup ( ) {
681+ onErrorCaptured ( ( err , instance , info ) => {
682+ fn ( err , info )
683+ return false
684+ } )
685+ return ( ) => h ( Child )
686+ } ,
687+ }
688+
689+ const Child = {
690+ setup ( ) {
691+ const foo = computed ( ( ) => {
692+ if ( trigger . value ) throw err
693+ return 1
694+ } )
695+ watch ( foo , ( ) => { } )
696+ return ( ) => null
697+ } ,
698+ }
699+
700+ render ( h ( Comp ) , nodeOps . createElement ( 'div' ) )
701+
702+ trigger . value = true
703+ await nextTick ( )
704+ expect ( fn ) . toHaveBeenCalledWith (
705+ err ,
706+ ErrorTypeStrings [ ErrorCodes . COMPONENT_UPDATE ] ,
707+ )
708+ } )
709+
673710 // native event handler handling should be tested in respective renderers
674711} )
Original file line number Diff line number Diff line change @@ -400,7 +400,10 @@ function doWatch(
400400 } else {
401401 // default: 'pre'
402402 job . flags ! |= SchedulerJobFlags . PRE
403- if ( instance ) job . id = instance . uid
403+ if ( instance ) {
404+ job . id = instance . uid
405+ job . i = instance
406+ }
404407 scheduler = ( ) => queueJob ( job )
405408 }
406409 effect . scheduler = scheduler
You can’t perform that action at this time.
0 commit comments