-
Notifications
You must be signed in to change notification settings - Fork 595
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
Storage: repeatedly streaming a readable from storage "freezes" after a a few times #335
Comments
Are you creating a new instance of a Readable Stream every time, or reusing one (eg do you call file.createReadStream once or for each request)? I think things get messy if you reusing streams that already consumed data. |
I call it for each request. My exact code is:
And my small gcloud module has:
So a new |
No, you're right in that you're creating a new file instance each request. Does every range request fail? When you see that it stops sending data, are there any similarities between other failed instances? -- as an example, is the byte count received always the same? |
No similarities, unluckily. It took me 5-6 minutes to get a freezing now (I'm deactivating caching in the browser to make it happen quicker), and the final log is completely different, in terms of values:
Worth mentioning that when it happens, it completely freezes my server (it doesn't answer any request at all, even unrelated ones). ps aux doesn't show high cpu use on the node process, btw. Let me know if some more tests would be useful, and I'll try them. |
And, to answer your first question: it doesn't happen on every ranged request. The first n ranged requests work perfectly fine, it freezes at the n+1, where n seems random. |
So far, I can't think of a reason the stream would fail. If anything, it sounds like it could be a caching issue somewhere upstream: request or the API itself. All that's returned from 'createReadStream' is a request instance. Is there any way you can produce a headless test case to recreate the behavior of the ranged requests and get it to reproduce the bug? |
Yep, here's to you. This kills (freezes) my server after a couple of minutes: https://gist.github.com/janesconference/22afe04aba3dde02814d |
Updated it with a deterministic version, still freezes it. |
Update: the deterministic gist freezes it after exactly 5 requests. |
I started off by plugging in "yahoo.com" as an endpoint, and everything ran smoothly. I then started testing directly with Still no answers, unfortunately, but I will try to play with it more tomorrow. |
You reproduced it. |
(Update: Tried to wait for a long time, but the server does not respond anymore after 5 iterations) |
Can you paste the exact code you're using (fill in the TODO part of your gist). I'm not able to reproduce. |
@stephenplusplus, do you mean I should send you the API endpoint I'm using on my server or send over the server code? I can probably semplify the code, in the second case, because it's a complex server with integrations with Mongodb and JWT. Btw, didn't you say yesterday that by plugging in range-stream you could observe your server stopping after 5 requests? |
I just need a test case that strips it down to the bare minimum; something I can run isolated from your environment so we can assure the bug is in gcloud. Of course, assume I have a bucket with files in it to test with. Maybe try the code from my comment on your gist and see if that reproduces the bug for you? Yesterday, when I inserted gcloud to your example, it was working, even though it was slow. Inserting range-stream did result in 5 successful attempts, then nothing, but only on the first run. And I still attribute that to my lack of patience, as I didn't notice until later attempts that if I waited long enough, the requests did come back (talking 1-2 seconds at first, 10-15 seconds at the slowest). |
Sorry, just found your comment with your version. Replaced with my data and what I get is:
Done never gets called again. |
No, it works for me. I'll re-run in a bit to see what I get today. Curious, if you take out range-stream from my example, does it work? |
Commenting out the line produces this result:
Seems to work. Maybe the culprit is |
This one broke my head a little bit. Try upgrading range-stream to 1.0.1: stephenplusplus/range-stream@261c989 |
Oh wow, I couldnt spot that at all! |
Phew! Thanks for reporting. We should win a debugging medal for this effort. |
You should :) |
* Make unify script recursive + clean up dependency conflicts * Restore travis.yml * Delete outdated text detection sample that duplicates detect.js * Fix failing KMS + vision tests by updating dependencies * Fix video tests using a bad cwd * Upgrade monitoring dependency + skip flaky monitoring tests * Fix DLP tests having wrong cwd * Fix failing vision test * Fix datastore tests * Update broken dependency * Update possibly broken compute engine dependency * Fix typos * Disable Node 4 testing * Revert deletion of outdated sample - @gguuss says we still use this. This reverts commit b7259c820fb011369c7b5badac82fcde26be008a. * Update dependency
- [ ] Regenerate this pull request now. Committer: @summer-ji-eng PiperOrigin-RevId: 424244721 Source-Link: googleapis/googleapis@4b6b01f Source-Link: googleapis/googleapis-gen@8ac83fb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOGFjODNmYmE2MDZkMDA4YzdlOGE0MmU3ZDU1YjY1OTZlYzRiZTM1ZiJ9
- [ ] Regenerate this pull request now. Committer: @summer-ji-eng PiperOrigin-RevId: 434859890 Source-Link: googleapis/googleapis@bc2432d Source-Link: googleapis/googleapis-gen@930b673 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOTMwYjY3MzEwM2U5MjUyM2Y4Y2ZlZDM4ZGVjZDdkM2FmYWU4ZWJlNyJ9
samples: pull in latest typeless bot, clean up some comments Source-Link: https://togithub.com/googleapis/synthtool/commit/0a68e568b6911b60bb6fd452eba4848b176031d8 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:5b05f26103855c3a15433141389c478d1d3fe088fb5d4e3217c4793f6b3f245e
Users can now use checksums for data integrity assurance when adding and accessing SecretVersions. PiperOrigin-RevId: 425369494 Source-Link: googleapis/googleapis@70d389c Source-Link: googleapis/googleapis-gen@cf92905 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2Y5MjkwNTY4Mjg0ZDJmMDk5YjlhMDBjYzgyYTJhMTMzYmU2ZGZkYSJ9 See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
... chore: update gapic-generator-ruby to the latest commit chore: release gapic-generator-typescript 1.5.0 Committer: @miraleung PiperOrigin-RevId: 380641501 Source-Link: googleapis/googleapis@076f7e9 Source-Link: googleapis/googleapis-gen@27e4c88
🤖 I have created a release \*beep\* \*boop\* --- ### [3.2.3](https://www.github.com/googleapis/nodejs-talent/compare/v3.2.2...v3.2.3) (2021-06-22) ### Bug Fixes * make request optional in all cases ([#335](https://www.github.com/googleapis/nodejs-talent/issues/335)) ([7ba1f51](https://www.github.com/googleapis/nodejs-talent/commit/7ba1f51db25cf37b33f9a611e031c7294112649a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
* Make unify script recursive + clean up dependency conflicts * Restore travis.yml * Delete outdated text detection sample that duplicates detect.js * Fix failing KMS + vision tests by updating dependencies * Fix video tests using a bad cwd * Upgrade monitoring dependency + skip flaky monitoring tests * Fix DLP tests having wrong cwd * Fix failing vision test * Fix datastore tests * Update broken dependency * Update possibly broken compute engine dependency * Fix typos * Disable Node 4 testing * Revert deletion of outdated sample - @gguuss says we still use this. This reverts commit b7259c820fb011369c7b5badac82fcde26be008a. * Update dependency
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/5fc9e824-cf7f-4f93-9bfe-6ba3aa84ec69/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@ba9918c
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip]
* Make unify script recursive + clean up dependency conflicts * Restore travis.yml * Delete outdated text detection sample that duplicates detect.js * Fix failing KMS + vision tests by updating dependencies * Fix video tests using a bad cwd * Upgrade monitoring dependency + skip flaky monitoring tests * Fix DLP tests having wrong cwd * Fix failing vision test * Fix datastore tests * Update broken dependency * Update possibly broken compute engine dependency * Fix typos * Disable Node 4 testing * Revert deletion of outdated sample - @gguuss says we still use this. This reverts commit b7259c820fb011369c7b5badac82fcde26be008a. * Update dependency
Hi all,
I'm trying to stream a file from my server to the client. Waiting from #318 to be closed, I'm using @stephenplusplus 's https://github.com/stephenplusplus/range-stream. By the way, this doesn't change the issue I'm seeing, which seems related to
createReadStream()
.First of all, what I do on the server on a ranged request is extracting the range from the request in the
start
andend
variables, then get a file:var file = resourceBucket.file(fileName);
create a readable:
var rStream = file.createReadStream()
then write a 206 on res and pipe the readable into a range request:
res.writeHead(206, header);
rStream.pipe(rangeStream(start, end)).pipe(res);
rangeStream is @stephenplusplus module, here modified with a few
console.log
statements to see what's happening:Initially everything works fine, the readable streams,
this.end
gets called and the file streams OK.But after a few times the client does ranged requests (specifically via an
<audio>
HTML element),rStream
seems to freeze and never send data torangeStream
again. Here is the log:As you can see, the code calls
next()
, but no data comes into it at all. This seems an issue withrStream
, and specifically with the readable. I also have an error handler onrStream
, which never gets called:Oddly enough, this seems to happen only when the range is 44 - end. But 44 being the size of the wav header, it's a typical range value, and that could be a red herring.
The text was updated successfully, but these errors were encountered: