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

Gatsby is not running the script again on route changes, causing problems when using the same function name in multiple scripts. #38449

Open
2 tasks done
Porush opened this issue Aug 10, 2023 · 0 comments
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby

Comments

@Porush
Copy link

Porush commented Aug 10, 2023

Preliminary Checks

Description

Hi, My website has multiple pages, and every page uses a different script. Every script has a single method with the same name. Now when I navigate from one page to another and call the method, it calls the method from the previous page's script. It works fine after reloading the page.

Reproduction Link

Gatsby v5 not supported by CodeSandbox or StackBlitz

Steps to Reproduce

  1. Create two or three pages along with their scripts.
  2. Add a console.log function with same name in all scripts.
  3. Navigate to all pages one by one, you will see different logs.
  4. Now navigate to another page and you will see that its still using function from last loaded script.

Expected Result

Print the log from the navigated page's script.

Actual Result

Printing log from the last newly loaded page's script.

Environment

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
  Binaries:
    Node: 18.17.1 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.3.1 - D:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.11.4
  Browsers:
    Edge: Spartan (44.22621.2134.0), Chromium (115.0.1901.200)
  npmPackages:
    gatsby: ^5.10.0 => 5.10.0
    gatsby-plugin-advanced-sitemap: ^2.1.0 => 2.1.0
    gatsby-plugin-dark-mode: ^1.1.2 => 1.1.2
    gatsby-plugin-git-lastmod: ^0.1.2 => 0.1.2
    gatsby-plugin-image: ^3.9.0 => 3.9.0
    gatsby-plugin-load-script: ^1.1.0 => 1.1.0
    gatsby-plugin-manifest: ^5.9.0 => 5.9.0
    gatsby-plugin-postcss: ^6.10.0 => 6.10.0
    gatsby-plugin-preact: ^7.10.0 => 7.10.0
    gatsby-plugin-react-head: ^1.1.0 => 1.1.0
    gatsby-plugin-sharp: ^5.9.0 => 5.9.0
    gatsby-plugin-sitemap: ^6.10.0 => 6.10.0
    gatsby-source-filesystem: ^5.10.0 => 5.10.0
    gatsby-transformer-gitinfo: ^1.1.0 => 1.1.0
    gatsby-transformer-sharp: ^5.9.0 => 5.9.0
  npmGlobalPackages:
    gatsby-cli: 5.10.0

Config Flags

No response

@Porush Porush added the type: bug An issue or pull request relating to a bug in Gatsby label Aug 10, 2023
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

1 participant