File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
services/static-webserver/client/source/class/osparc/store Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,8 @@ qx.Class.define("osparc.store.Services", {
106106 return this . __servicesPromisesCached [ key ] [ version ] ;
107107 }
108108
109- return new Promise ( ( resolve , reject ) => {
109+ // Create a new promise
110+ const promise = new Promise ( ( resolve , reject ) => {
110111 if (
111112 useCache &&
112113 this . __isInCache ( key , version ) &&
@@ -145,6 +146,14 @@ qx.Class.define("osparc.store.Services", {
145146 delete this . __servicesPromisesCached [ key ] [ version ] ;
146147 } ) ;
147148 } ) ;
149+
150+ // Store the promise in the cache
151+ // The point of keeping this assignment outside of the main Promise block is to
152+ // ensure that the promise is immediately stored in the cache before any asynchronous
153+ // operations (like fetch) are executed. This prevents duplicate requests for the
154+ // same key and version when multiple consumers call getService concurrently.
155+ this . __servicesPromisesCached [ key ] [ version ] = promise ;
156+ return promise ;
148157 } ,
149158
150159 getStudyServices : function ( studyId ) {
You can’t perform that action at this time.
0 commit comments