-
-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate User-Agent when app starts, thus avoiding storing it on disk #929
Conversation
@andersk @timabbott Can you please have a look? If this feels right, we can refine it :) |
This certainly looks plausible. It's probably a good idea to test this against a Zulip development server configured with a Python |
@manavmehta can you test this against a zulip test server and note down the UA in the following cases - |
Reason: The new-server-form calls domain-util which calls system-utils afresh. Workaround as suggested by @abhigyank ebb1238
@timabbott @andersk any fixes in your mind or should we go with this? |
A more robust approach would be for the renderer process to ask the main process for the user-agent with |
@andersk That was a great suggestion. P.S. If you want, I can send you the log where I printed a bunch of UAs received by the test server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, this looks good to me, except for a few comments I've left that you may want to consider.
Great work, @manavmehta!
The goal is to avoid the race condition where we see Either use const userAgentPromise: Promise<str> = ipcRenderer.invoke('fetch-user-agent');
export async function getUserAgent(): string {
return `ZulipElectron/${app.getVersion()} ${await userAgentPromise}`;
} (which requires adjusting its callers to be |
@andersk I tested 37c420a against Zulip test server and logging both. Couldn't find a single instance of the race condition. But since theoretically, the condition is possible, I think we may go with Though it adds a delay, which is probably lesser than a millisecond and better than the race condition anyway. |
Fixes: zulip#921. Co-authored-by: Anders Kaseorg <anders@zulipchat.com>
I edited this to use |
Fixes: #921
What's this PR do?
Fetch and send UA from main process and use ipc call to catch it in renderer process: system-util.ts and use it elsewhere in the app as required, avoiding storing it on disk.
Any background context you want to provide?
Please refer #921
You have tested this PR on: