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

refactor(nuxi): hard restart with communication channel #19423

Merged
merged 8 commits into from Mar 3, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Mar 3, 2023

πŸ”— Linked issue

Followup unresolved fixes from #18641

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 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

Aligning (more) with next version of CLI, this PR improves dev wrapper implementation:

  • Use fork to open a communication channel
  • Request hard restart via process.send signaling
  • Stop the listener and gracefully stop and unallocated nuxt before restarting
  • Small fixes for restart handling edge cases
  • Make sure old child is closed before starting new one

πŸ“ Checklist

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

@codesandbox
Copy link

codesandbox bot commented Mar 3, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@danielroe
Copy link
Member

Experimenting with #19394, I'm getting this error:

 ERROR  [uncaughtException] Channel closed                                                                                                                                    15:03:45

  at new NodeError (node:internal/errors:393:5)
  at target.send (node:internal/child_process:740:16)
  at packages/nuxi/src/commands/dev.ts:99:21
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Following that error, programmatic restarts no longer work.

@pi0
Copy link
Member Author

pi0 commented Mar 3, 2023

Can you directly reproduce it in this branch? (you can use a hook in playground/nuxt.config) What is your node version?

Co-authored-by: Daniel Roe <daniel@roe.dev>
@danielroe
Copy link
Member

I can reproduce reliably after a couple of saves. Reproduction:

git checkout feat/modules-dir
git merge --squash origin/fix/cli-restart
pnpm nuxi dev test/fixtures/basic
# modify test/fixtures/basic/modules/example.ts

Running on Node v18.12.1

@pi0
Copy link
Member Author

pi0 commented Mar 3, 2023

Try again with latest commit :)

@danielroe
Copy link
Member

Seems to be working well πŸ‘

@danielroe danielroe requested a review from antfu March 3, 2023 16:21
@danielroe danielroe added the 3.x label Mar 3, 2023
@danielroe danielroe changed the title fix(cli): hard restart with communication channel refactor(cli): hard restart with communication channel Mar 3, 2023
@danielroe danielroe added the cli label Mar 3, 2023
@danielroe danielroe changed the title refactor(cli): hard restart with communication channel refactor(nuxi): hard restart with communication channel Mar 3, 2023
@danielroe danielroe merged commit 8fa3fba into main Mar 3, 2023
@danielroe danielroe deleted the fix/cli-restart branch March 3, 2023 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants