Page MenuHomePhabricator

[web/native] Send platform details on http communication
ClosedPublic

Authored by michal on Jun 28 2023, 3:18 AM.
Tags
None
Referenced Files
F3530604: D8351.id28377.diff
Wed, Dec 25, 3:32 AM
F3530600: D8351.id28352.diff
Wed, Dec 25, 3:26 AM
F3530598: D8351.id28570.diff
Wed, Dec 25, 3:20 AM
F3529162: D8351.diff
Tue, Dec 24, 3:59 PM
Unknown Object (File)
Sun, Dec 22, 4:04 AM
Unknown Object (File)
Fri, Dec 20, 12:43 AM
Unknown Object (File)
Fri, Dec 20, 12:43 AM
Unknown Object (File)
Fri, Dec 20, 12:43 AM
Subscribers

Details

Summary

https://linear.app/comm/issue/ENG-3905/platform-details-arent-updated-on-http-communication
Using redux state introduced in the previous diff, send platform details when calling http endpoints as needed. Also updated the websocket to only send the platform details when needed and not on every initialization.

Depends on D8350

Test Plan

Disable the websocket, update version, trigger endpoint call, check if redux state is updated.
Enable the websocket, wait for initialization, check if redux state is updated.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

lib/utils/action-utils.js
213

This is fine because this used in logging in the redux state will be updated anyway.

keyserver/src/responders/handlers.js
58–61

This is actually risky because if it throws an exception, nothing will catch it.

The issue is that if the promise rejects without being caught, Node.js treats this a bit like an exception being thrown and not caught.

You'll see an "unhandled promise rejection" warning in our current version of Node. But in more recent versions of Node, this would crash the whole app.

Await the setCookiePlatformDetails

keyserver/src/responders/handlers.js
58 ↗(On Diff #28276)

Does setCookiePlatformDetails really need to block policiesValidator? If not, can you find a way to execute these simulatneously?

You can also use handleAsyncPromise here if you don't want to block execution. Not sure what the intention is here

Set new platform details concurrently with policy validation. We need to block execution before running endpoint logic, because it might depend on the version

kamil added inline comments.
lib/socket/socket.react.js
111 ↗(On Diff #28352)

nit: this is more // Redux state rather than // keyserver olm sessions specific props

also, I think there is a possibility that lastCommunicatedPlatformDetails can be passed as undefined.

lib/utils/call-server-endpoint.js
110–114 ↗(On Diff #28352)

Are you sure this is correct? I think when there is no lastCommunicatedPlatformDetails we should send platform details

web/socket.react.js
58–60 ↗(On Diff #28352)

nit: I would prefer to see this selector a couple of lines higher, grouped with other selectors

This revision is now accepted and ready to land.Jul 4 2023, 2:45 AM

Address review

lib/utils/call-server-endpoint.js
110–114 ↗(On Diff #28352)

lastCommunicatedPlatformDetails is set to null only when calling it from fetchNewCookieFromNativeCredentials. In this case, we don't want to send platform details because they will be later invalidated anyway (fetchNewCookieFromNativeCredentials also calls login).

lib/socket/socket.react.js
535 ↗(On Diff #28570)