Closed lessmost closed 2 weeks ago
Hi @lessmost,
Thanks for the report and analysis.
2. ElectronWebSocketConnectionSource is first bound to WebSocketConnectionSource at L36, but also bound as a FrontendApplicationContribution at L74
The electron code should never end up in the browser-only case as it's not needed there. So the cause of the issue seems to be this check in the frontend-generator which erroneously ends up in the electron path for browser-only.
Bug Description:
The browser-only Theia example application still tries to create a WebSocket connection.
Steps to Reproduce:
http://localhost:3000/socket.io/?EIO=4&transport=polling&t=P0cgjyV
and wait for a while, there should be a lots of socket.io request 404 error
Possible Cause
The socket.io request is triggered by WebSocketConnectionSource:createWebSocket, which is triggered by postConstruct in WebSocketConnectionSource.
In
electron-messaging-frontend-module.ts
which in included by the Browser-only Theia application, ElectronWebSocketConnectionSource is first bound to WebSocketConnectionSource at L36, but also bound as a FrontendApplicationContribution at L74In
messaging-frontend-only-module.ts
, although WebSocketConnectionSource is unbind at L24, the ElectronWebSocketConnectionSource FrontendApplicationContribution multiInject still exists. So when application start, ElectronWebSocketConnectionSource will be initialized anyway.Maybe we can separate ElectronWebSocketConnectionSource from FrontendApplicationContribution and close the socket by an dynamic FrontendApplicationContribution?
#L74
Additional Information