openedx / openedx/frontend-template-application

ErrorPage fails on getLocale() because i18n isn't initialized.

Open
#590 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
38
Forks
67
Avg merge
34m
Merged PRs (30d)
2

Description

Description:

Some (maybe all?) MFEs have issues with ErrorPages and i18n.

The ErrorPage is invoked before either the Locale is set or Intl is initialized as a whole.

This should likely later be remediated in any MFEs that have this issue.

Repro Steps
  1. Up devstack (im from REV so, we tend to grab lms+redis+ecommerce)
  2. Once up, start Payment MFE (we dont use docker for this as there is an issue with the image we have yet to fix, its alo not germaine) npm ci && npm start
  3. Stop LMS
  4. Open Payment MFE in a Browser http://localhost:1998/
Technical/Additional Details

Specific Error: getLocale called before configuring i18n. Call configure with messages first.
Stack Trace:

Call Stack
 getLocale
  node_modules/@edx/frontend-platform/i18n/lib.js:273:11
 ErrorPage
  node_modules/@edx/frontend-platform/react/ErrorPage.js:82:115
 renderWithHooks
  node_modules/react-dom/cjs/react-dom.development.js:14803:18
 mountIndeterminateComponent
  node_modules/react-dom/cjs/react-dom.development.js:17482:13
 beginWork
  node_modules/react-dom/cjs/react-dom.development.js:18596:16
 HTMLUnknownElement.callCallback
  node_modules/react-dom/cjs/react-dom.development.js:188:14
 Object.invokeGuardedCallbackDev
  node_modules/react-dom/cjs/react-dom.development.js:237:16
 invokeGuardedCallback
  node_modules/react-dom/cjs/react-dom.development.js:292:31
 beginWork$1
  node_modules/react-dom/cjs/react-dom.development.js:23203:7
 performUnitOfWork
  node_modules/react-dom/cjs/react-dom.development.js:22154:12

2023-05-30_18_56_54

Code Ptr (ErrorPage initialization point): https://github.com/openedx/frontend-template-application/blob/master/src/index.jsx#L28

Community Example (learner MFE): https://discuss.openedx.org/t/when-attempting-to-enter-a-courses-home-on-learning-mfe-error-getlocale-called-before-configuring-i18n/9756/1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/index.jsx, especially the ErrorPage initialization point, then inspect ErrorPage.js and the getLocale call in @edx/frontend-platform/i18n/lib.js. Reproduce the failure by stopping LMS and opening the Payment MFE at http://localhost:1998/. Done means ErrorPage no longer fails when i18n has not yet been configured.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, internationalization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.