nitrojs / nitrojs/nitro

Can nitro provide a way to communicate between the main thread and the worker?

Open
#1,990 3 comments 2 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.