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

feat(deps): update fastify-websocket to 1.x.x, fix tests #96

Merged
merged 2 commits into from
Jan 3, 2020
Merged

feat(deps): update fastify-websocket to 1.x.x, fix tests #96

merged 2 commits into from
Jan 3, 2020

Conversation

SkeLLLa
Copy link
Contributor

@SkeLLLa SkeLLLa commented Jan 1, 2020

Update fastify-websockets to 1.x.x and fix tests.

@@ -123,6 +123,7 @@ module.exports = class SubscriptionConnection {
payload
}))
} catch (e) {
/* istanbul ignore next */
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was covered before, why it is not anymore? Maybe we should add a new test.

Copy link
Contributor Author

@SkeLLLa SkeLLLa Jan 2, 2020

Choose a reason for hiding this comment

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

It was covered because of server tried to send data to already closed socket. And as far as I understood it was triggered just occasionally as side-effect of some test.

I've added one test, but I'd rather refactor send message method slightly:

  1. Check if socket is open before trying to send anything to it. Don't know how it would impact on performance, but it seems better approach for me.
  2. Since it called in a loop calling JSON.stringify in it may result in overhead. I think it would be better to call it once when subscription message arrives and send method should accept only strings as messages.
  3. May be use fast-json-stringify in here, but also don't know if it will add some benefit.
    In this case as bench shows fast-json-stringify is slower than JSON.stringify.

But I think this would be in other PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed!

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 914e52b into mercurius-js:master Jan 3, 2020
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.

2 participants