Skip to content

Connecting to websocket leaves app in unstable state #50291

@yharaskrik

Description

@yharaskrik

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

When Hydration is being used and websockets (repro is using socket.io) are being connected to the client never becomes stable thus hydration never occurs.

For a while now we have always not initialized websockets while on the server (using isPlatformBrowser(PLATFORM_ID)) because they completely hang the universal server (I now understand this is because the ApplicationRef does not become stable) but now when using hydration, hydration never occurs for the same reason just not on the client.

There should be a way to use hydration alongside websockets (or have a mechanism in place to not include socket connections in the app becoming stable? Although that likely has ramifications).

At the very least there should be guidance/docs/errors around Hydration + Sockets so that we can build real-time applications that are also SSR'd.

While this repro is using Socket.io to demostrate the issue we also encountered issues with GraphQL Subscriptions which are also websockets.

Please provide a link to a minimal reproduction of the bug

https://github.com/yharaskrik/socket-io-ng-hydration-issue

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions