Skip to content

fixing crash in attemptTokenRefresh when adobeIMS.refreshToken() returns null - #876

Open
arugupta1992 wants to merge 1 commit into
stagefrom
fixtokenlog
Open

fixing crash in attemptTokenRefresh when adobeIMS.refreshToken() returns null#876
arugupta1992 wants to merge 1 commit into
stagefrom
fixtokenlog

Conversation

@arugupta1992

Copy link
Copy Markdown
Collaborator

Splunk log:
{"event":{"name":"error_fetching_access_token","category":"acrobat","subcategory":"compress-pdf"},"content":{},"source":{"user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36","lang":"en","app_name":"unity","url":"https://www.adobe.com/acrobat/online/compress-pdf.html"},"user":{"locale":"en","isAuthenticated":"false","type":["frictionless_new_user"]},"error":{"type":-54,"desc":{"message":"Error getting IMS access token: {\"stack\":\"TypeError: Cannot read properties of undefined (reading 'error')\n at attemptTokenRefresh (https://www.adobe.com/unitylibs/scripts/utils.js:64:22)\n at async getImsToken (https://www.adobe.com/unitylibs/scripts/utils.js:81:28)\n at async isGuestUser (https://www.adobe.com/unitylibs/scripts/utils.js:115:18)\n at async ActionBinder.isSignedOut (https://www.adobe.com/unitylibs/core/workflow/workflow-acrobat/action-binder.js:208:20)\n at async ActionBinder.initialize (https://www.adobe.com/unitylibs/core/workflow/workflow-acrobat/action-binder.js:203:5)\n at async ActionBinder.acrobatActionMaps (https://www.adobe.com/unitylibs/core/workflow/workflow-acrobat/action-binder.js:797:28)\n at async HTMLInputElement.<anonymous> (https://www.adobe.com/unitylibs/core/workflow/workflow-acrobat/action-binder.js:897:13)\",\"message\":\"Cannot read properties of undefined (reading 'error')\"}","type":"token_error"}}}

Root Cause:
When adobeIMS.refreshToken() returns null, (!refreshResult?.error) crashes throwing TypeError

Test URLs:
Before: https://main--da-dc--adobecom.aem.live/acrobat/online/sign-pdf?unitylibs=stage
After: https://main--da-dc--adobecom.aem.live/acrobat/online/sign-pdf?unitylibs=fixtokenlog

@aem-code-sync

aem-code-sync Bot commented Aug 24, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run all PSI checks
  • Re-run failed PSI checks
  • Re-sync branch
Commits

const { tokenInfo } = window.adobeIMS ? await window.adobeIMS.refreshToken() : {};
return tokenInfo;
const res = window.adobeIMS ? await window.adobeIMS.refreshToken() : null;
return res?.tokenInfo ?? { token: null, isGuestToken: true };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isGuestToken: true in this case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user with no valid token is treated as guest user rather than erroring out. Followed the same convention here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is not the invalid case, this is the case where adobeIMS has not been loaded yet. Do we want to retry in this case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already retrying once in the parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants