@@ -4,7 +4,7 @@ import ssri from "ssri";
44import clone from "clone" ;
55import posixPath from "node:path/posix" ;
66import { setTimeout } from "node:timers/promises" ;
7- import { withTimeout , Mutex } from "async-mutex" ;
7+ import { Mutex } from "async-mutex" ;
88import { getLogger } from "@ui5/logger" ;
99
1010const log = getLogger ( "fs:Resource" ) ;
@@ -52,8 +52,8 @@ class Resource {
5252
5353 /* States */
5454 #isModified = false ;
55- // Mutex to prevent access/modification while content is being transformed. 100 ms timeout
56- #contentMutex = withTimeout ( new Mutex ( ) , 100 , new Error ( "Timeout waiting for resource content access" ) ) ;
55+ // Mutex to prevent access/modification while content is being transformed
56+ #contentMutex = new Mutex ( ) ;
5757
5858 // Tracing
5959 #collections = [ ] ;
@@ -404,20 +404,23 @@ class Resource {
404404 }
405405 // Then make sure no other operation is currently modifying the content and then lock it
406406 const release = await this . #contentMutex. acquire ( ) ;
407- const newContent = await callback ( this . #getStream( ) ) ;
408-
409- // New content is either buffer or stream
410- if ( Buffer . isBuffer ( newContent ) ) {
411- this . #content = newContent ;
412- this . #contentType = CONTENT_TYPES . BUFFER ;
413- } else if ( typeof newContent === "object" && typeof newContent . pipe === "function" ) {
414- this . #content = newContent ;
415- this . #contentType = CONTENT_TYPES . STREAM ;
416- } else {
417- throw new Error ( "Unable to set new content: Content must be either a Buffer or a Readable Stream" ) ;
407+ try {
408+ const newContent = await callback ( this . #getStream( ) ) ;
409+
410+ // New content is either buffer or stream
411+ if ( Buffer . isBuffer ( newContent ) ) {
412+ this . #content = newContent ;
413+ this . #contentType = CONTENT_TYPES . BUFFER ;
414+ } else if ( typeof newContent === "object" && typeof newContent . pipe === "function" ) {
415+ this . #content = newContent ;
416+ this . #contentType = CONTENT_TYPES . STREAM ;
417+ } else {
418+ throw new Error ( "Unable to set new content: Content must be either a Buffer or a Readable Stream" ) ;
419+ }
420+ this . #contendModified( ) ;
421+ } finally {
422+ release ( ) ;
418423 }
419- this . #contendModified( ) ;
420- release ( ) ;
421424 }
422425
423426 /**
0 commit comments