From 29b4056f2c6fbc32029a567572669b9711806538 Mon Sep 17 00:00:00 2001 From: Fidel Coria Date: Tue, 22 Dec 2020 16:03:21 -0600 Subject: [PATCH] delay window close by 200 ms --- .changeset/purple-turtles-float.md | 2 +- plugins/auth-backend/src/lib/flow/authFlowHelpers.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.changeset/purple-turtles-float.md b/.changeset/purple-turtles-float.md index 2e5688bf11..8736a7315f 100644 --- a/.changeset/purple-turtles-float.md +++ b/.changeset/purple-turtles-float.md @@ -2,4 +2,4 @@ '@backstage/core-api': patch --- -Remove race condition in loginPopup +Delay auth loginPopup close to avoid race condition with callers of authFlowHelpers. diff --git a/plugins/auth-backend/src/lib/flow/authFlowHelpers.ts b/plugins/auth-backend/src/lib/flow/authFlowHelpers.ts index 22ffc7af88..86a615e721 100644 --- a/plugins/auth-backend/src/lib/flow/authFlowHelpers.ts +++ b/plugins/auth-backend/src/lib/flow/authFlowHelpers.ts @@ -56,7 +56,9 @@ export const postMessageResponse = ( var originInfo = {'type': 'config_info', 'targetOrigin': origin}; (window.opener || window.parent).postMessage(originInfo, '*'); (window.opener || window.parent).postMessage(JSON.parse(authResponse), origin); - window.close(); + setTimeout(() => { + window.close(); + }, 100 * 2); // double the interval of the core-api lib/loginPopup.ts `; const hash = crypto.createHash('sha256').update(script).digest('base64');