File tree Expand file tree Collapse file tree 2 files changed +10
-37
lines changed
Expand file tree Collapse file tree 2 files changed +10
-37
lines changed Original file line number Diff line number Diff line change @@ -623,20 +623,17 @@ export class TreeCheckout implements ITreeCheckoutFork {
623623
624624 private readonly onAfterChange = ( event : SharedTreeBranchChange < SharedTreeChange > ) : void => {
625625 this . editLock . lock ( ) ;
626- try {
627- this . #events. emit ( "beforeBatch" , event ) ;
628- if ( event . change !== undefined ) {
629- const revision =
630- event . type === "rebase"
631- ? this . #transaction. activeBranch . getHead ( ) . revision
632- : event . change . revision ;
633-
634- this . applyChange ( event . change . change , revision ) ;
635- }
636- this . #events. emit ( "afterBatch" ) ;
637- } finally {
638- this . editLock . unlock ( ) ;
626+ this . #events. emit ( "beforeBatch" , event ) ;
627+ if ( event . change !== undefined ) {
628+ const revision =
629+ event . type === "rebase"
630+ ? this . #transaction. activeBranch . getHead ( ) . revision
631+ : event . change . revision ;
632+
633+ this . applyChange ( event . change . change , revision ) ;
639634 }
635+ this . #events. emit ( "afterBatch" ) ;
636+ this . editLock . unlock ( ) ;
640637 if ( event . type === "append" ) {
641638 for ( const commit of event . newCommits ) {
642639 this . validateCommit ( commit ) ;
Original file line number Diff line number Diff line change @@ -782,30 +782,6 @@ describe("sharedTreeView", () => {
782782 view . checkout . transaction . abort ( ) ;
783783 assert . equal ( view . checkout . transaction . isInProgress ( ) , false ) ;
784784 } ) ;
785-
786- // Regression test for transactions erroneously double lock
787- itView ( "does not double-lock when event handler throws during transaction" , ( { view } ) => {
788- Tree . on ( view . root , "nodeChanged" , ( ) => {
789- throw new Error ( "Event handler error" ) ;
790- } ) ;
791-
792- let caughtError : unknown ;
793- try {
794- Tree . runTransaction ( view , ( ) => {
795- view . root . insertAtStart ( "A" ) ; // This triggers nodeChanged, which throws
796- } ) ;
797- } catch ( error ) {
798- caughtError = error ;
799- }
800-
801- // We should get the original error, not the double-lock error (0xaa7)
802- assert ( caughtError instanceof Error , "Expected an error to be thrown" ) ;
803- assert . equal (
804- caughtError . message ,
805- "Event handler error" ,
806- "Expected the original error message, not a double-lock error" ,
807- ) ;
808- } ) ;
809785 } ) ;
810786
811787 describe ( "disposal" , ( ) => {
You can’t perform that action at this time.
0 commit comments