Skip to content

Conversation

mattiaslvv
Copy link

@mattiaslvv mattiaslvv commented Sep 17, 2025

There is an issue with the SSE-connection logic.
A check exists if (url !== this.endpoint) { return next() } where this.endpoint default starts with a /, example /@angular-architects/native-federation:build-notifications and the incoming url variable gets stripped to being without a leading /. Therefore, it always goes into the above if-clause, resulting in setupSSEConnection being unreachable, ultimately never setting up an SSE build-notification connection properly.

This fix checks if this.endpoint has a leading /, if so it adds a leading / onto the url variable for proper comparison.

@Aukevanoost
Copy link
Collaborator

Aukevanoost commented Oct 2, 2025

Hi @mattiaslvv,

I tried to reproduce the issue but I currently was unable to. Do you happen to have a particular setup where the issue occurs?

With a normal Angular monorepo with a host and mfe, the error does not seem to occur (at the mfe logs).

-------------------------------------------------
before: /@angular-architects/native-federation:build-notifications     // req.url
after: /@angular-architects/native-federation:build-notifications      // url
goal: /@angular-architects/native-federation:build-notifications       // this.endpoint
 INFO  [Federation SSE] Client connected. Active connections: 1

It also seems like you can customize the endpoint in the options:
https://github.com/angular-architects/module-federation-plugin/blob/1923ddcabe49ddab2aff88601a53cbeb4cd98b58/libs/native-federation/src/builders/build/schema.json#L68C5-L82C6

@mattiaslvv
Copy link
Author

mattiaslvv commented Oct 9, 2025

Hi @mattiaslvv,

I tried to reproduce the issue but I currently was unable to. Do you happen to have a particular setup where the issue occurs?

With a normal Angular monorepo with a host and mfe, the error does not seem to occur (at the mfe logs).

-------------------------------------------------
before: /@angular-architects/native-federation:build-notifications     // req.url
after: /@angular-architects/native-federation:build-notifications      // url
goal: /@angular-architects/native-federation:build-notifications       // this.endpoint
 INFO  [Federation SSE] Client connected. Active connections: 1

It also seems like you can customize the endpoint in the options: https://github.com/angular-architects/module-federation-plugin/blob/1923ddcabe49ddab2aff88601a53cbeb4cd98b58/libs/native-federation/src/builders/build/schema.json#L68C5-L82C6

Ok, very interesting. In our monorepo which does not have any configured values for this step at all (fully default), our build-notifications does not set up properly because of the above logic failing. The incoming path gets stripped of the leading "/" in removeBaseHref(req) but the default endpoint path has it, so it never goes through the comparison. We always get "http://localhost:3007/@angular-architects/native-federation:build-notifications 404 (Not Found)" because of this, not setting up the connection properly.

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

Successfully merging this pull request may close these issues.

2 participants