Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

attempt to getTokens after call to logout results in exception

未关闭
#39 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@jakefeasel 已经在做这个了。

开始于 2021年12月8日。

  • #40 来自 @jakefeasel —— 未关闭

评估

难度
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:

  1. Click "Logout" after token string appears
  2. Click "Login" after logout request completes
主要语言
JavaScript
星标
52
派生
16
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ForgeRock/appAuthHelper 的其他 Issue

查看 ForgeRock/appAuthHelper 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。