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.

Module becomes `undefined` after refresh due to cyclic dependencies

See original GitHub issue

I’m experiencing a bug where upon changing a file, one of my modules becomes undefined (causing part of the page to disappear).

I’ve mostly reduced my repro case. It seems related to cyclic dependencies. Repro steps:

  1. Clone https://github.com/sophiebits/refresh-cycle-repro

  2. Run yarn and yarn start, then visit http://localhost:7002/. You’ll see the text “Hello: 100”.

  3. If you edit the “Hello” (in App.js), it updates properly.

  4. If you edit the “100” (in SurveyOverview.js), the 100 disappears until next page reload.

    This is because the DashboardPage import in routes.js becomes undefined (as you can see from the console logs). If you check the same import a tick later, it is correctly populated.

Not sure whether the bug is in react-refresh-webpack-plugin, react-refresh, or webpack.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sophiebitscommented, Apr 24, 2020

@Timer I think you’re the better judge of that! But it does appear that you successfully copied my code into a test case. 😅 Does the fact that it passes CI mean that this works correctly in @next/react-refresh-utils already?

0reactions
pmmmwhcommented, Sep 11, 2021

Closing as it is marked as won't fix in upstream.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Imported module is undefined when there's a circular ...
Imported module is undefined when there's a circular dependency between the modules when one module is in the parent directory of the other...
Read more >
How to solve this basic ES6-module circular dependency ...
For reference, I'm trying this in Meteor, in which case the first module to be evaluated is module B, but that means that...
Read more >
Webpack 5 Module Federation: A game-changer in JavaScript ...
A scalable solution to sharing code between independent applications has never been convenient, and near impossible at scale.
Read more >
typeerror class extends value undefined is not a constructor or ...
If anyone else sees this error, the first thing to look for is circular dependencies. Import file A into B, B into some...
Read more >
Circular Dependency - A progressive Node.js framework
A circular dependency occurs when two classes depend on each other. For example, class A needs class B, and class B also needs...
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