You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by li...@apache.org on 2022/10/20 01:30:14 UTC

[incubator-devlake] 03/06: fix: confirm all graphql task finish

This is an automated email from the ASF dual-hosted git repository.

likyh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 767ad4659e3d2409d2adb4f89f3a710e48c23850
Author: linyh <ya...@meri.co>
AuthorDate: Wed Oct 19 19:42:02 2022 +0800

    fix: confirm all graphql task finish
---
 plugins/helper/graphql_async_client.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/plugins/helper/graphql_async_client.go b/plugins/helper/graphql_async_client.go
index 91be1728..fcd46aef 100644
--- a/plugins/helper/graphql_async_client.go
+++ b/plugins/helper/graphql_async_client.go
@@ -131,12 +131,15 @@ func (apiClient *GraphqlAsyncClient) NextTick(task func() errors.Error) {
 	// to make sure task will be enqueued
 	apiClient.waitGroup.Add(1)
 	go func() {
-		defer apiClient.waitGroup.Done()
 		select {
 		case <-apiClient.ctx.Done():
 			return
 		default:
 			go func() {
+				// if set waitGroup done here, a serial of goruntine will block until son goruntine finish.
+				// But if done out of this go func, so task will run after waitGroup finish
+				// I have no idea about this now...
+				defer apiClient.waitGroup.Done()
 				apiClient.checkError(task())
 			}()
 		}