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

fix(node-cluster): fix node cluster preset #2893

Closed
wants to merge 2 commits into from

Conversation

OskarLebuda
Copy link

@OskarLebuda OskarLebuda commented Nov 19, 2024

πŸ”— Linked issue

Fix #2892

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Resolves #2892

This change addresses the issue where, after the nitro build (unbuild), the code from node-server ends up in the same scope as node-cluster (see screen bellow). In the current implementation, the primary cluster executes the server code, and subsequently, when workers attempt to execute the same code, they encounter an error because the port is already in use by the primary. By wrapping the server code into a separate, exported function, we avoid these scope conflicts and port clashes, ensuring that each worker operates independently without interference.

build index.mjs:
image

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

This entry is also used for default nitro server-preset that requires the entrypoint itself to immediately start listening and this PR breaks it!

image

I think we should find better fix or at least duplicate this entry to be specific solution for node_cluster.

Copy link
Author

Choose a reason for hiding this comment

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

Eh.. I didn't know about that :/ Sorry, my mistake 😭

@pi0
Copy link
Member

pi0 commented Nov 19, 2024

Thanks for PR and note about unbuild output it was important to help finding issue ❀️

I think I found a better alternative specific to this issue: ~> #2894

@pi0 pi0 closed this Nov 19, 2024
@OskarLebuda
Copy link
Author

Thanks for PR and note about unbuild output it was important to help finding issue ❀️

I think I found a better alternative specific to this issue: ~> #2894

Thanks for the reply πŸ˜„ Yea, your solution is much better then mine

@OskarLebuda OskarLebuda deleted the fix-node-cluster-preset branch November 19, 2024 19:46
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.

Running node-cluster preset build throwing EADDRINUSE errors
2 participants