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

Uncaught TypeError: t.replace is not a function (A page wasn't found for "[object Object]") #4067

Closed
fpoumian opened this issue Feb 16, 2018 · 11 comments

Comments

@fpoumian
Copy link
Contributor

fpoumian commented Feb 16, 2018

Description

I'm getting the following browser error on a production site generated by Gatsby.

A page wasn't found for "[object Object]"  loader.js:136 
Uncaught TypeError: t.replace is not a function
    at T (loader.js:144)
    at Object.getResourcesForPathname (loader.js:318)
    at o (production-app.js:85)
    at Object.onClick (index.js:204)
    at r.handleClick (Link.js:50)
    at Object.l (react-dom.production.min.js:26)
    at Object.invokeGuardedCallback (react-dom.production.min.js:25)
    at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.production.min.js:25)
    at h (react-dom.production.min.js:30)
    at m (react-dom.production.min.js:32)
react-dom.production.min.js:27 

The error doesn't show up when the page first loads, but it does whenever I click on any of the internal links (all of which use Gatsby Link). This in turn causes the site to react way slower when navigating the site. Oddly enough I don't have this problem during development (the Links work as intended there), but only in the production site itself.

I have worked in a couple of Gatsby sites already and never had this problem before, so I have no idea what I'm doing wrong this time.

Environment

Gatsby version: 1.9.158
Node.js version: 8.9.3
Operating System: Ubuntu 16.04

Actual result

Whenever I click on any of the links the previously described error pops up and the site takes way longer to load the new page.

Expected behavior

The site should navigate to the linked route quickly and without any errors (just as it does in the development site.)

...

@m-allanson
Copy link
Contributor

Can you recreate the issue on a local build of the site? e.g. if you do gatsby build and then gatsby serve.

@fpoumian
Copy link
Contributor Author

Hi @m-allanson ,
Yes, unfortunately, I'm having the exact same issue with a local build. I have also tried disabling some Gatsby plugins which I hadn't used on other sites before, but the result is always the same. Any idea of what the underlying problem might be?

@m-allanson
Copy link
Contributor

Hmm. As a baseline try deleting your node_modules, .cache and public directories, then reinstall and rebuild.

Your error is coming from loader.js, if you're comfortable digging in to the code you could set up gatsby-dev-cli and have a look around at what that [object Object] is.

Alternatively if you can post an example repo I can have a look?

@KyleAMathews
Copy link
Contributor

I wonder if it's related to this? #3407

@u840903
Copy link

u840903 commented Feb 20, 2018

I had the same issue but it resolved when I updated Gatsby from ^1.9.102 to 1.9.203.

@ChrisSki
Copy link

ChrisSki commented Mar 20, 2018

@KyleAMathews @m-allanson

I'm currently getting this issue only in production. Not when I build and serve locally. I have deleted my node_modules, .cache and public folders.

Gatsby: 1.9.238
Node: 8.9.4
MacOS: 10.13.3

@ChrisSki
Copy link

@fpoumian did you find a fix for this?

@altaywtf
Copy link
Contributor

Hey guys, it seems like a gatsby-link related issue. We were using 1.6.34, upgraded to 1.6.39 and encountered with this problem. Downgrading to 1.6.34 resolved.

I think there's an argument mismatch on the function chain triggered by react-router -> gatsby-link -> loader.js

@ChrisSki
Copy link

ChrisSki commented Mar 26, 2018

@altayaydemir This didn't seem to work for me. Here's my package.json. Please let me know if you see any other issues. This is keeping me from pushing anything to prod.

update: This downgrade did work. I was still using ^1.6.39 in my package.json

@sean6bucks
Copy link

@KyleAMathews Looks like the update to allow an object for "to" prop in #3407 correctly updated the production only block on Line 142 to only send the path/pathname
nsimonson@d458fe7#diff-f0712f4b9f6079d8d9ba1ea7fa2c95d5L142

But was then reverted back to passing the whole state with this update for adding to history #3802

https://github.com/gatsbyjs/gatsby/pull/3802/files#diff-f0712f4b9f6079d8d9ba1ea7fa2c95d5L160

which seems to be what is causing the loader.js to throw this log error only in built versions

@KyleAMathews
Copy link
Contributor

Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants