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

Component generate script not properly copying placeholder thumbnail #6562

Open
davidmenendez opened this issue Dec 10, 2024 · 1 comment
Open
Labels
Sev 4 Not visible to or noticeable to users. Affects minor functionality, no workaround needed. type: bug 🐛 Something isn't working

Comments

@davidmenendez
Copy link
Contributor

This was noticed when looking at the example gallery and noticing that a lot of newer components & patterns are missing thumbnails for the gallery.

After some investigation I tracked it down to the generate script used to create new component folders. i tracked down the specific code to this particular line. currently readFileSync is using a utf8 encoding and when yarn generate is used the thumbnail it creates looks like this in vscode

Image

You can actually see the corrupted thumbnail files in our repo. Here's one such example for BigNumbers.

What I found was that when I omitted the utf8 encoding that the image was created successfully.

Image

The Node documentation for readFileSync says the following:

If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

I'm not well versed in how the node filesystem reads various file types and how different encodings impact them. My guess at this point is that at some point a newer Node version changed how readFileSync works and that caused the file corruptions. The code was originally introduced three years ago, so it was definitely using an older version of Node.

I don't know if there's a better solution to this than just checking for thumbnail.png and omitting the encoding. I think it would be helpful to pull someone in with more experience and knowledge on this topic to help direct us towards a working solution.

@elycheea
Copy link
Contributor

@davidmenendez thanks for the investigation and popping this into the dev channel. Don’t forget to self-triage this one. :)

@ljcarot ljcarot added type: bug 🐛 Something isn't working Sev 4 Not visible to or noticeable to users. Affects minor functionality, no workaround needed. and removed status: needs triage 🕵️‍♀️ labels Dec 18, 2024
@ljcarot ljcarot moved this from Needs triage 🧐 to Needs refinement 🤓 in Carbon for IBM Products Dec 18, 2024
@ljcarot ljcarot moved this from Needs refinement 🤓 to Backlog 🌋 in Carbon for IBM Products Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sev 4 Not visible to or noticeable to users. Affects minor functionality, no workaround needed. type: bug 🐛 Something isn't working
Projects
Status: Backlog 🌋
Development

No branches or pull requests

3 participants