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

Bugfix/603 hono node ws duplicate event listeners #605

Conversation

inaridiy
Copy link
Contributor

@inaridiy inaridiy commented Jul 1, 2024

Fixed a bug when multiple connections are created in node-ws, as pointed out in #603

Summary of changes:

  • Fixed bug with multiple connections in node-ws
  • Add relevant tests
  • Fixed an issue that prevented access to node.js-specific APIs within upgradeWebocket handlers

Copy link

changeset-bot bot commented Jul 1, 2024

🦋 Changeset detected

Latest commit: 58925fd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/node-ws Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@yusukebe
Copy link
Member

yusukebe commented Jul 1, 2024

@inaridiy Thanks!

@nakasyou Can you review this?

Copy link
Contributor

@nakasyou nakasyou left a comment

Choose a reason for hiding this comment

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

Thank you for fixing the bug, I wrote a review, please check it.


;(async () => {
const events = await createEvents(c)
const ws = await nodeUpgradeWebSocket(c.env.incoming)
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about accepting { server: { incoming: request, outgoing: undefined } } as Env?

When user use env as custom value, WebSocket helper may not work.

References: honojs/hono#2645, honojs/hono#2696, honojs/hono#2812, honojs/hono#2595 (comment).

Copy link
Contributor Author

@inaridiy inaridiy Jul 1, 2024

Choose a reason for hiding this comment

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

Thank you for your review.

First, there are many theories about the implementation of { server: { incoming: request, outgoing: undefined } }, but I consider this a minimal change to fix a bug.

Secondly, this is just my subjective view.
I see env as an area to store values given by the runtime.
Rather than storing values in the env area, I think a Variables area and middleware is a more natural way of doing this.

Again, I am not familiar with HonoJS core ideas, so this is subjective.

Copy link
Member

Choose a reason for hiding this comment

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

@nakasyou @inaridiy

Accepting { server: { incoming: request, outgoing: undefined } for Env is a good idea! But, as @inaridiy said, we don't have to add the change about it to this PR. And you can create another PR after merging this. Shall we go with it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you do about this problem? Once we have discussed how to use env, should I reflect that discussion?

@nakasyou @yusukebe

Copy link
Member

Choose a reason for hiding this comment

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

Let's merge this first without including Env things!

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe yusukebe merged commit 967fd48 into honojs:main Jul 4, 2024
1 check passed
@yusukebe
Copy link
Member

yusukebe commented Jul 4, 2024

@inaridiy

Looks good! Let's go with this. Thanks!

@github-actions github-actions bot mentioned this pull request Jul 4, 2024
@inaridiy inaridiy deleted the bugfix/603-hono-node-ws-duplicate-event-listeners branch July 4, 2024 05:54
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.

3 participants