Can nitro provide a way to communicate between the main thread and the worker?
Open
Nobody has claimed this yet.
enhancement
v2
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Describe the feature
Hi, Nitro is a great project!
I'm creating a vite plugin servite based on nitro, and I want to send some data to the worker renderer after starting dev, but now nitro seems to lack a way to communicate between the main thread and the worker.
Is it possible to add a hook to expose the worker instance?
// src/dev/server.ts
export function createDevServer() {
async function _reload() {
currentWorker = await initWorker(workerEntry);
await nitro.hooks.callHook("dev:worker", currentWorker);
}
}
Additional information
- Would you be willing to help implement this feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/dev/server.ts and read createDevServer, _reload, and the initWorker call. Determine how a dev:worker hook could expose the worker instance for communication with the main thread, then verify that the resulting hook behavior matches the requested Vite-plugin use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100