attempt to getTokens after call to logout results in exception
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript
调研方向
Reproduce the Chrome and Firefox failures using the listed logout-then-login steps, then start in appAuthHelper.js around lines 259-281 and appAuthHelperFetchTokensBundle.js around line 46. Trace the service-worker token request after logout and verify that calling getTokens after logout no longer produces an unhandled DOMException or DataCloneError.
由索引模型根据 Issue 内容生成。
描述
In Chrome, the following exception is unhandled when getTokens is called after logout:
Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'ServiceWorker': Port at index 0 is already neutered.
at Object.<anonymous> (https://localhost:3000/static/js/vendors~main.chunk.js:67061:28)
(anonymous) @ appAuthHelper.js:272
Promise.then (async)
(anonymous) @ appAuthHelper.js:266
Promise.then (async)
(anonymous) @ appAuthHelper.js:264
(anonymous) @ appAuthHelper.js:281
registerIdentityProxy @ appAuthHelper.js:259
(anonymous) @ appAuthHelper.js:114
postMessage (async)
(anonymous) @ appAuthHelperFetchTokensBundle.js:46
Promise.then (async)
(anonymous) @ appAuthHelperFetchTokensBundle.js:46
2../TokenManager @ appAuthHelperFetchTokensBundle.js:46
t @ appAuthHelperFetchTokensBundle.js:46
(anonymous) @ appAuthHelperFetchTokensBundle.js:46
3../appAuthHelperFetchTokens @ appAuthHelperFetchTokensBundle.js:46
t @ appAuthHelperFetchTokensBundle.js:46
s @ appAuthHelperFetchTokensBundle.js:46
(anonymous) @ appAuthHelperFetchTokensBundle.js:46
However, with Firefox one gets React error boundary catching the error, resulting in the more cryptic, maybe it tried to serialize
Unhandled Rejection (DataCloneError): The object could not be cloned.
I used the following component in React in order to test the workflow.
import React, { useEffect, useState } from 'react';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import AppAuthHelper from 'appauthhelper';
import { Toolbar } from '@mui/material';
// Make the authorization request
export const AuthTest = () => {
const [data, setData] = useState<any>(null);
useEffect(() => {
AppAuthHelper.init({
clientId: 'warden.mobile',
scopes: 'openid profile',
'authorizationEndpoint': 'https://localhost:44320/provider/auth',
'tokenEndpoint': 'https://localhost:44320/provider/token',
'revocationEndpoint': 'https://localhost:44320/provider/token/revocation',
tokensAvailableHandler: function (claims: any, id_token: any, interactively_logged_in: any) {
const data = { claims, id_token, interactively_logged_in };
// eslint-disable-next-line no-console
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>', data);
setData(data);
},
renewCooldownPeriod: 1,
oidc: true,
identityProxyPreference: 'serviceWorker', // Can be either "XHR" or "serviceWorker"
renewStrategy: 'authCode', // Can be either "authCode" or "refreshToken"
redirectUri: 'appAuthHelperRedirect.html', // Can be a relative or absolute url
serviceWorkerUri: 'appAuthServiceWorker.js' // Can be a relative or absolute url
}).then(() => {
AppAuthHelper.getTokens();
});
}, []);
return (
<div>
<button onClick={() => {
AppAuthHelper.getTokens();
}}>Login</button>
{ JSON.stringify(data, null, 2)}
<button onClick={() => {
setData(null);
AppAuthHelper.logout();
}}>Logout</button>
</div>
);
};
In order to reproduce this error, these steps are taken:
- Click "Logout" after token string appears
- Click "Login" after logout request completes
- 主要语言
- JavaScript
- 星标
- 52
- 派生
- 16
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ForgeRock/appAuthHelper 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 55/100
ForgeRock/appAuthHelper#68 · 2 个 reaction ·
-
Cannot read properties of undefined (reading 'clientId'): appAuthHelperFetchTokensBundle.js:46:635未关闭
难度 3/5 1-2 天 新手友好度 38/100
ForgeRock/appAuthHelper#67 ·
-
难度 5/5 一周以上 新手友好度 25/100
ForgeRock/appAuthHelper#64 ·
-
难度 5/5 一周以上 新手友好度 25/100
ForgeRock/appAuthHelper#62 ·
-
难度 4/5 3-5 天 新手友好度 35/100
ForgeRock/appAuthHelper#60 ·
查看 ForgeRock/appAuthHelper 的全部 Issue
相似的 Issue
-
Harden bayesian-waves-bg.js: add prefers-reduced-motion, pointer-events guard, and hidden-tab pause未关闭
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 1/5 1 小时以内 新手友好度 90/100
njitacm/njit-acm-website#109 ·
-
type: bug
难度 2/5 1-3 小时 新手友好度 76/100
blamechris/chroxy#8579 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
modusensus/dsh-mneme#411 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复