SchweizerischeBundesbahnen/scion-workbench

Error when embedding a microfrontend in a view microfrontend

danielwiehl opened this issue · 0 comments

Describe the bug

When embedding a microfrontend in a microfrontend view and if the embedded microfrontend is not qualified to access the view capability, @scion/workbench-client of the embedded microfrontend reports the error Uncaught TypeError: Cannot read properties of undefined (reading 'metadata').

To Reproduce

Steps to reproduce the behavior:

  1. Provide private view capability in app 1
  2. Provide public microfrontend capability in app 2
  3. Declare an intention to microfrontend capability in app 1
  4. Add sci-router-outlet to the view microfrontend of app 1
  5. Navigate to the microfrontend capability in the sci-router-outlet, e.g. in the constructor of the view
  6. Open the view
  7. See the error logged to the console

Analysis

Since the workbench microfrontend integration propagates the view context to any nested level, the embedded microfrontend consequently constructs a view handle. However, the view capability lookup may fail if the microfrontend is not qualified to access the view capability, causing the reported error in ɵworkbench-view.ts#lookupViewCapabilityAndShareReplay.

Expected behavior

It should be revisited whether the view context should be exclusively available to the view microfrontend. Propagating the context hardly makes sense because the embedded microfrontend usually does not know its embedding context.