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
🐛 Bug Report: fetch:plain:file fails with stream is not readable #17072
Comments
Im happy to provide a PR, but I wouldnt know where to start with this. |
@gavlyukovskiy are you finding it works for you? |
@punkle It does work for me:
I can't access your repository, but for mine it works well. |
@punkle well, I tried different combinations and it looks like it fails occasionally, especially first couple of seconds after starting with I have tried adding more logging to
but didn't find anything unusual:
It's always 200 and readable true, even when Backstage task fails with
|
I've added more debug logs in various places and also close listener
and I think I know what is the problem:
so body is closed before we could read it, but I have no idea what closes it, I didn't find any |
@gavlyukovskiy thanks for looking into it. Unfortunately I may not be able to help with identifying what might be causing that. |
Hi @gavlyukovskiy, I have the same problem, it seems to be related to private repository files. When I try to get the
|
I wonder would someone in the @backstage/catalog-maintainers group be able to help us here. I believe the issue is being surfaced when accessing the buffer of the URL reader which I would expect would work in this case. Perhaps this task is not using the url reader correctly? |
Ironically, it appears to work with the URL from the tests, Meanwhile, it fails for |
@eytanhanig it is a little odd that it works some of the time. I am not sure yet what the pattern is. |
I wonder if this could be a node-fetch issue? Maybe moving over to using the built in fetch in node, and |
@benjdlambert can you elaborate a little? Which import would get us the fetch you are suggesting? At the moment the github url reader is using this: What are you suggesting to try? |
I'm suggesting to use the new built in
|
I think you can even install that package as a seperate dependency too to backport it to older versions of node if you don't have it already. |
Sorry for the message spam, but there's also this docs here which might be of interest using the streams https://undici.nodejs.org/#/docs/api/Dispatcher?id=example-1-basic-get-stream-request |
@benjdlambert something like this #17632 |
Have there been any updates on this? |
Hey! I had the same issue and I have managed to fix the problem changing the order of calls in the fetchFile function. const res = await reader.readUrl(readUrl);
- await fs.ensureDir(path.dirname(outputPath));
- const buffer = await res.buffer();
+ const buffer = await res.buffer();
+ await fs.ensureDir(path.dirname(outputPath));
await fs.outputFile(outputPath, buffer.toString()); Please comment if this fix also works for you. |
Hmm that's an unexpected fix if that works 🤷 Looks like a race condition to me, I wondered if this was also perhaps related to the #18002 issue that was previously fixed recently? |
Hey @benjdlambert , I agree with you that it is an unexpected fix. It took me a while to discover it and, sincerely, I don´t know why this change fixes the problem. |
@eytanhanig @pcgqueiroz can you try the latest version of backstage 1.16 and see if you can reproduce it with this? And if you can, can we get a reproducible example that we can try with so we can dig into this further? |
Hey, has there been any progress/updates on this? |
I've got
and I'm facing the issue |
@pedronastasi can you update to the latest versions and see if the problem still persists? We made some changes in 1.16 but without reproduction case it's hard to see if we've fixed it or not. |
We're on 1.17.5, and have the same issue. And can confirm that it works fine by fetching from public repositories, but when fetching from our org, it fails with |
Hey @alper98 would it be possible for you to create a reproduction repo or something with a basic |
I've used |
@brunosantosnet is it possible that you can setup a minimal reproduction repository for this so we can dig in further? Also what change caused this to start breaking and failing? 🙏 |
@benjdlambert my scenario is the worst possible. There are repositories that using |
For people that have this issue, is it Node 20 or are we seeing it on Node 18 too? |
I think I have a fix, it's a similar fix to the other stream bug that we had. I managed to replicate this locally, but it doesn't happen every time, so I think that this works as I've not been able to reproduce it one using this fix. |
Can we verify that this is fixed by bumping to the latest
|
Maybe you got your answer a while ago, but I was able to fix this issue by moving on to the 0.20.0-next.3 version of Cheers! |
Yep I think that this got released in the mainline release of 1.20 so should be fixed for everyone from that version 🤞 |
Hi @benjdlambert, unfortunately this is still the case on Backstage 1.20.3, but with gitlab url in format
but it's not consistent, approximately every second request fails. |
@gavlyukovskiy can you create a reproduction repo or something so that we can reproduce this easier? These things are hard to dig into otherwise. |
@benjdlambert I've created a reproducer, though I cannot reproduce it with latest version v1.21.0 (or
then after using the template with url We will upgrade our Backstage to the latest version tomorrow and I'll let you know if we still see that issue on our production instance. |
@benjdlambert ah, I thought that your fix was in 1.20.3, but it only got into 1.21.0. Looks like it did fix the issue 👍 |
Ah apologies - yeah looks like it did go out in 1.21.0, nice at least it's fixed! 🎉 |
📜 Description
When I created the following template step it fails with an error:
👍 Expected behavior
i expect it to fetch the file and write it to the workspace directory at the targetPath
👎 Actual Behavior with Screenshots
It fails with the folling error:
👟 Reproduction steps
Create a template with the step shown above and run it.
📃 Provide the context for the Bug.
No response
🖥️ Your Environment
No response
👀 Have you spent some time to check if this bug has been raised before?
🏢 Have you read the Code of Conduct?
Are you willing to submit PR?
Yes I am willing to submit a PR!
The text was updated successfully, but these errors were encountered: