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

Interrupted download stream does not retry correctly after some bytes are sent #1822

Closed
ddelgrosso1 opened this issue Mar 23, 2022 · 6 comments
Assignees
Labels
api: storage Issues related to the googleapis/nodejs-storage API. external This issue is blocked on a bug with the actual product. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ddelgrosso1
Copy link
Contributor

Creating an issue to track this. Currently, if the request body stream of a download is interrupted / forcefully closed the library is not correctly retrying. After some initial investigation it appears that this may be related to a problem in node-fetch as outlined here. Currently investigating possible solutions as the version in which this was fixed for node-fetch requires the ability to utilize ESM.

@ddelgrosso1 ddelgrosso1 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Mar 23, 2022
@ddelgrosso1 ddelgrosso1 self-assigned this Mar 23, 2022
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Mar 23, 2022
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Jun 21, 2022
@shaffeeullah shaffeeullah added the external This issue is blocked on a bug with the actual product. label Aug 10, 2022
@shaffeeullah
Copy link
Contributor

Tagged as external because this is an issue with node-fetch / teeny-request

@shaffeeullah shaffeeullah added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 20, 2022
@ddelgrosso1
Copy link
Contributor Author

Updating this as a self reminder of sorts: this appears to have been fixed in node-fetch v3.1.1 . It does not appear that the fix was ever back ported to 2.x.

@ddelgrosso1
Copy link
Contributor Author

Possibly related as well: node-fetch/node-fetch#1064. This appears to have been backported and released with 2.6.9. We moved to an async iterator with this PR: #1925 this was around the same time we noticed this bug.

@ddelgrosso1
Copy link
Contributor Author

To my last comment, I was able to verify hanging behavior with 2.6.7 but get a correct error with 2.6.9 of node-fetch.

@ddelgrosso1
Copy link
Contributor Author

import express from 'express';
import fetch from 'node-fetch';

const app = express();
const port = 5000;
let count = 0;
app.get('/', (req, res) => {
    setInterval(() => {
        count++;
        res.write('hello');
        if (count >= 10) {
            res.socket?.destroy();
        }
    }, 1000);
});
app.listen(port, () => console.log(`Running on port ${port}`));

try {
    const response = await fetch('http://localhost:5000', {
        method: 'GET'
    });
    for await (const chunk of response.body) {
        console.log(chunk);
    }
} catch (e) {
    console.error(e);
}
console.log('Finished async iterator');

With node-fetch v2.6.7 this will reliably recreate unresponsiveness. With 2.6.9 the error is thrown / caught correctly.

@danielduhh
Copy link

Duplicate of: #2193. Fixing the node-fetch issue will fix this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. external This issue is blocked on a bug with the actual product. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants