Impossible to use worker_thread (server side) due to wrong path

Open
#67,063 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, next.js, typescript, webpack

Research direction

Clone the reproduction repository at the linked URL, run npm install and npm run dev, then compare the generated worker path with the expected /_next/server/ location. Check whether the same resolution problem occurs during next build; done means the server-side worker resolves correctly in both next dev and next build.

Written by the indexing model from the issue text.

Description

bug Webpack
Link to the code that reproduces this issue

https://github.com/ale-grosselle/worker-thread-bug

To Reproduce
  1. Clone this repository
  2. Run npm install
  3. Run npm run dev
  4. On the console you will see the following error: "uncaughtException: Error: Cannot find module _/_next/rsc_app_lib_create-invoice_ts.js
Current vs. Expected behavior

This statement:

new Worker(new URL('./create-invoice.ts', import.meta.url));

is being converted to the wrong path:
'/_next/_rsc_app_lib_create-invoice_ts.js' instead of '/_next/server/_rsc_app_lib_create-invoice_ts.js'

Screenshot 2024-06-20 at 14 26 51
Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.12.1
  npm: 10.5.1
  Yarn: 1.22.19
  pnpm: 8.15.5
Relevant Packages:
  next: 15.0.0-canary.28 // There is a newer canary version (15.0.0-canary.38) available, please upgrade! 
  eslint-config-next: 15.0.0-rc.0
  react: 19.0.0-rc-6230622a1a-20240610
  react-dom: 19.0.0-rc-6230622a1a-20240610
  typescript: 5.2.2
Next.js Config:
  output: N/A
 ⚠ There is a newer canary version (15.0.0-canary.38) available, please upgrade! 
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue
Which area(s) are affected? (Select all that apply)

Webpack

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

No response

Dominant language
JavaScript
Stars
142k
Forks
32.5k
Avg merge
2d 13h
Merged PRs (30d)
334

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.

More from vercel/next.js

All issues in vercel/next.js

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.