question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$RefreshReg$ is not defined in web worker after upgrading to 9.4.0

See original GitHub issue

Bug report

I believe this is a React Refresh-related issue.

Potentially relevant:

Describe the bug

After upgrading to Next.js 9.4.0, workers throw the following exception on load:

Uncaught ReferenceError: $RefreshReg$ is not defined
    at Module.eval (blocks.ts:239)
    at eval (blocks.ts:296)
    at Module../shared/blocks.ts (48ba4b417edc794a158b.worker.js:311)
    at __webpack_require__ (48ba4b417edc794a158b.worker.js:29)
    at Module.eval (WorldChunk.ts:12)
    at eval (WorldChunk.ts?c4f7:22)
    at Module../lib/Data/WorldChunk.ts (48ba4b417edc794a158b.worker.js:115)
    at __webpack_require__ (48ba4b417edc794a158b.worker.js:29)
    at Module.eval (WorldChunkReader.worker.ts?024a:1)
    at eval (WorldChunkReader.worker.ts?024a:21)

To Reproduce

  1. Configure worker-loader like so in next.config.js:
config.module.rules.unshift({
  test: /\.worker\.(js|ts|tsx)$/,
  loader: "worker-loader",
  options: {
    name: "static/[hash].worker.js",
    publicPath: "/_next/",
  },
});

// Overcome webpack referencing `window` in chunks
config.output.globalObject = "self";
  1. Load a worker
  2. See error

Expected behavior

No error, workers load successfully as in Next 9.3

Screenshots

image image

System information

  • OS: macOS
  • Browser (if applies) Chrome
  • Version of Next.js: 9.4.0
  • Version of Node.js: 13.12.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:14
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
hbeckericommented, Jul 3, 2020

I began seeing this same issue when I upgraded to next 9.4 from 9.3. It’s only impacting dev for me, when I deployed it to vercel, the error was not there

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: $RefreshReg$ is not defined - Stack Overflow
In my case, this error was happening when overwriting Webpack's mode option. After removing the line below I stopped receiving the error.
Read more >
Web Workers API - W3Schools
A web worker is a JavaScript running in the background, without affecting the performance of the page. What is a Web Worker? When...
Read more >
Threading the web with module workers - web.dev
Module workers make it easy to unblock the main thread by moving expensive code to a background thread while keeping the ergonomic and ......
Read more >
Web Worker in Javascript for beginners ... - YouTube
Web Worker in Javascript for beginnersWEB WORKER 2021Web worker was introduced with HTML5 and it is a way to use multithreading in browsers....
Read more >
Understanding and Using Web Workers - CODE Magazine
Event-Based Communication. Events are how your application and the Web Worker script communicate with each other. When you start a Web Worker, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found