Skip to content
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

warm up connection #399

Merged
merged 6 commits into from
Sep 10, 2020
Merged

warm up connection #399

merged 6 commits into from
Sep 10, 2020

Conversation

thesyncim
Copy link
Member

@thesyncim thesyncim commented Aug 12, 2020

Submit a pull request

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

@github-actions
Copy link
Contributor

github-actions bot commented Aug 12, 2020

Size Change: +296 B (0%)

Total Size: 191 kB

Filename Size Change
dist/browser.es.js 41 kB +60 B (0%)
dist/browser.full-bundle.min.js 26.8 kB +56 B (0%)
dist/browser.js 41.2 kB +60 B (0%)
dist/index.es.js 41 kB +60 B (0%)
dist/index.js 41.3 kB +60 B (0%)

compressed-size-action

src/client.js Outdated
@@ -56,6 +56,7 @@ export class StreamChat {
const defaultOptions = {
timeout: 3000,
withCredentials: false, // making sure cookies are not sent
warmUp: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets roll with this disabled first

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/client.js Outdated
const handshake = await this.wsConnection.connect();
this.connectionID = this.wsConnection.connectionID;
if (this.options.warmUp) {
// wait for warm up connection to complete
await warmUp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a fire and forget is better for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@thesyncim thesyncim requested a review from tbarbugli August 12, 2020 14:43
src/client.js Outdated
@@ -56,6 +56,7 @@ export class StreamChat {
const defaultOptions = {
timeout: 3000,
withCredentials: false, // making sure cookies are not sent
warmUp: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a code comment about what does this mean exactly?

createUserToken(user),
);

let t0 = new Date().getTime();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using performance would be better for more accurate numbers since uses counters for relative time than real time system

https://nodejs.org/api/perf_hooks.html

src/client.js Outdated
@@ -491,6 +492,9 @@ export class StreamChat {
case 'patch':
response = await this.axiosInstance.patch(url, data, requestConfig);
break;
case 'options':
response = await this.axiosInstance.options(url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
response = await this.axiosInstance.options(url);
response = await this.axiosInstance.options(url, requestConfig);

The api_key request header should be included, so the preflight request doesn't fail

@vishalnarkhede vishalnarkhede merged commit 74a9121 into master Sep 10, 2020
@delete-merged-branch delete-merged-branch bot deleted the warmup-tls-conn branch September 10, 2020 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants