diff --git a/.changeset/purple-turtles-float.md b/.changeset/purple-turtles-float.md new file mode 100644 index 0000000000..8736a7315f --- /dev/null +++ b/.changeset/purple-turtles-float.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-api': patch +--- + +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..e70aa0bfee 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); // same as the interval of the core-api lib/loginPopup.ts (to address race conditions) `; const hash = crypto.createHash('sha256').update(script).digest('base64');