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

Typescript error TP1001 when creating a Web Worker in Next.js 15.1.3 #74621

Open
farzadsoltani opened this issue Jan 7, 2025 · 6 comments
Open
Labels
Turbopack Related to Turbopack with Next.js.

Comments

@farzadsoltani
Copy link

Link to the code that reproduces this issue

https://github.com/farzadso/workers-issue

To Reproduce

Run npm run dev and you can see the issue.

Current vs. Expected behavior

There should be no errors in the console.

This is the error I see:

 ⚠ ./app/page.tsx:9:22
error TP1001 new Worker("/workers/timer.js") is not statically analyse-able
   7 |
   8 |   useEffect(() => {
>  9 |     ticker.current = new Worker("/workers/timer.js");
     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  10 |   }, []);
  11 |   return <div>Test</div>;
  12 | }

If I remove --turbopack from the dev script it works fine.

I noticed this happening after my upgrade to Next.js 15 and using Turbopack for dev builds.

The Web Worker is being created dynamically, and it works fine, so I don't see any issues with the functionality.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.2.0: Fri Dec  6 19:02:12 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 20.15.1
  npm: 10.7.0
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 15.2.0-canary.0 // Latest available version is detected (15.2.0-canary.0).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

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

Not sure

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

next dev (local)

Additional context

No response

@farzadsoltani farzadsoltani added the bug Issue was opened via the bug report template. label Jan 7, 2025
@ztanner ztanner added the Turbopack Related to Turbopack with Next.js. label Jan 8, 2025
@sam-skydio
Copy link

also experiencing this issue after attempting to turn on Turbopack, would appreciate some guidance here.

@farzadsoltani
Copy link
Author

@sam-skydio I'm just ignoring it for now as it seems to be working on the client side and not causing any issues when building for prod as the prod build doesn't use Turbopack.

@bbsweb
Copy link

bbsweb commented Jan 12, 2025

use window.Worker instead of Worker

ticker.current = new window.Worker("/workers/timer.js");

@farzadsoltani
Copy link
Author

use window.Worker instead of Worker

ticker.current = new window.Worker("/workers/timer.js");

Thank you. That actually worked and suppressed it.

@mischnic
Copy link
Contributor

You could also use one of these

new Worker(/* webpackIgnore: true */ "/workers/timer.js");
new Worker(/* turbopackIgnore: true */ "/workers/timer.js");

@farzadsoltani
Copy link
Author

You could also use one of these

new Worker(/* webpackIgnore: true / "/workers/timer.js");
new Worker(/
turbopackIgnore: true */ "/workers/timer.js");

Thanks. Is this documented anywhere?

@samcx samcx removed the bug Issue was opened via the bug report template. label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

6 participants