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.

JS modules are loaded twice

See original GitHub issue

Bug report

Describe the bug

JS modules seem to be loaded twice

To Reproduce

Steps to reproduce the behavior:

  1. Go to ‘https://www.nextjs.org’ (or your own built site)
  2. Click on ‘developer console’ in e.g. Chrome
  3. See Network tab
  4. Do a hard refresh (E.g. CTRL + SHIFT + R)
  5. Sort resources by name
  6. Look at loaded JS modules. They appear twice in the resource list, but are not retrieved from cache

Expected behavior

All required resources to be loaded just once.

Screenshots

image

System information

  • OS: Ubuntu Linux
  • Browser Chrome
  • Version of Next.js: 9.1.1 - 9.3.0

Additional context

When disabling granular loading in next.js config, the issue seems resolved.

    experimental: {
      granularChunks: false,
      css: false
    }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

14reactions
andrei-svistunoucommented, Nov 25, 2020

Hi @Timer ,

I still can reproduce this issue on a lot of sites, including nextjs.org image

Could you, please, clarify this behaviour? Is it expected?

3reactions
helfi92commented, Feb 8, 2021

We’re seeing the same behavior as well on the latest version of Next.js 10.0.6

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Happens When a Module Is Imported Twice?
A JavaScript module is evaluated just once. When imported multiple times from the same path, the same module instance is returned.
Read more >
Requiring the same module twice in Node.js - Stack Overflow
Importing the same thing multiple times should have no effect, because loaded modules are cached. · Require has a cache that basically imports ......
Read more >
DOMContentLoaded twice - Questions - three.js forum
It appears that the importmap (es-module) shim causes document.DOMContentLoaded to be called twice. Why? For example, the following code ...
Read more >
JavaScript modules for grumpy developers from 2005
Now what if we try loading our module twice, like this? const module1 = await import(url); const module2 = await import(url);. The browser...
Read more >
What happens if I import the same module twice? - JS IQ
If multiple modules imports the same module then angular evaluates it only once (When it encounters the module first time). It follows this...
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