-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
createRemoteFileNode doesn't use inferred fileType to check existence #24453
Comments
Thanks for report! I can reproduce this locally, and investigating now |
Hmm I actually can't reproduce it anymore. I was getting different error because |
Interesting 🤔 the website does seem to have just dissappeared. I will create a new example later |
@pieh I forked the repository to use Confirmed I get the same error on the second develop without cleaning cache:
|
Thanks! Opened pull request with proposed fix - #24613 |
Description
Sometimes we need to use APIs of which not all asset URLs contain the extension of the file type, this is something that Gatsby is capable of handling because the createRemoteFileNode will call the file-type npm package to infer file types when the extension is not in the URL, nor in the createRemoteFileNode options. This covers a lot of use-cases, but far from all.
When we need to use an images endpoint for example, where some of the image file extensions are not part of the asset URLs. On the first
gatsby build
orgatsby develop
in a new environment this works fine, but in consecutive runs of thegatsby develop
command, the system will try to look in its local cache whether the file node is still there. This step will fail given that the inferred file extension is not used to check whether said node exists, resulting in errors like this one:But when you would go look, it could be that said file does exist as
300x300.png
or300x300.jpg
implying that Gatsby doesn't use the inferred extension to reuse the file node it created.Potential solutions could be to use a wildcard for the extension when the checking for a fileNode fails or using the inferred file extension in looking for a locally created fileNode by the createRemoteFileNode method.
Steps to reproduce
A minimal reproduction was created by @chpio already in #21901: https://github.com/chpio/gatsby-remote-wo-ext
Expected result
On consecutive runs of
gatsby develop
, without cleaning the cache in between, the local file nodes should be used to speed up the development process.Actual result
The Gatsby development setup crashed, looking for a file that does exist, but it cannot find because it doesn't look for the filed with extension.
Environment
The text was updated successfully, but these errors were encountered: