瀏覽代碼

fix job timed out error

master
peter 5 年之前
父節點
當前提交
dad45d4f56

+ 4
- 4
src/backend/Components/PubSub/PubSub.ts 查看文件

23
         }
23
         }
24
     ]
24
     ]
25
 
25
 
26
-    publish = ( topic: string, msg: UpdateType ) => {
26
+    publish = async (topic: string, msg: UpdateType ) => {
27
         if(!this.subs[topic]) this.subs[topic] = {}
27
         if(!this.subs[topic]) this.subs[topic] = {}
28
-        Object.entries(this.subs[topic]).forEach(([uuid, callback]:[string, Function]) => {
28
+        await Promise.all(Object.entries(this.subs[topic]).map(async ([uuid, callback]:[string, Function]) => {
29
             try{
29
             try{
30
-                callback(msg)
30
+                await callback(msg)
31
             }catch(e){
31
             }catch(e){
32
                 delete this.subs[topic][uuid]
32
                 delete this.subs[topic][uuid]
33
             }
33
             }
34
-        })
34
+        }))
35
     }
35
     }
36
 
36
 
37
     subscribe = async (topic:string, callback:(p:UpdateType)=>any) : Promise<SubscriptionResponse<{topic: string}>> => {
37
     subscribe = async (topic:string, callback:(p:UpdateType)=>any) : Promise<SubscriptionResponse<{topic: string}>> => {

+ 5
- 5
src/backend/Components/Shoutbox/Shoutbox.ts 查看文件

38
         this.log.push(msg)
38
         this.log.push(msg)
39
     }
39
     }
40
 
40
 
41
-    private broadcast = (uuid:string, msg: ShoutMessage) => {
42
-        Object.values(this.subs).forEach((cb:any) => {
41
+    private broadcast = async (uuid:string, msg: ShoutMessage) => {
42
+        await Promise.all(Object.values(this.subs).map(async (callback:any) => {
43
             try{
43
             try{
44
-                cb(msg)
44
+                await callback(msg)
45
             }catch(e){
45
             }catch(e){
46
-                this.unsubscribe(uuid)
46
+                delete this.subs[uuid]
47
             }
47
             }
48
-        })
48
+        }))
49
     }
49
     }
50
 
50
 
51
     getFeed = async () : Promise<ShoutMessage[]> => {
51
     getFeed = async () : Promise<ShoutMessage[]> => {

+ 3
- 3
src/frontend/src/app/frontcraft/pages/pages-layout.component.ts 查看文件

27
     title: 'Loot Rules',
27
     title: 'Loot Rules',
28
     link: '/frontcraft/rules',
28
     link: '/frontcraft/rules',
29
   },{
29
   },{
30
-  icon: "shield",
31
-  title: 'Armory',
32
-  link: '/frontcraft/armory'
30
+    icon: "shield",
31
+    title: 'Armory',
32
+    link: '/frontcraft/armory'
33
   }]
33
   }]
34
   
34
   
35
   constructor(
35
   constructor(

Loading…
取消
儲存