question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: read ECONNRESET when resizing image in Storage

See original GitHub issue

I’d like to resize an image stored in Firebase Storage with Firebase Functions.

Based on this example : https://github.com/firebase/functions-samples/blob/master/quickstarts/thumbnails/functions/index.js I try to write a function triggered by a Database event.

Here is the most interesting part of the code :

const gcs = require('@google-cloud/storage')();

...

const bucket = gcs.bucket('...appspot.com');
const originalFilepath = myObject.picture1Url;
const tempFilePath = '/tmp/myThumbnail';

console.log('1');

return bucket
    .file(originalFilepath)
    .download({
        destination: tempFilePath
    })
    .then(() => {

        console.log('2');

    });

Everything looks fine to me. However the code never go to the console.log(‘2’); and I get this error :

Error: read ECONNRESET
    at exports._errnoException (util.js:1026:11)
    at TCP.onread (net.js:569:26)

Does somebody know what could be the error?

Thank you

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
nicolasgarniercommented, Mar 22, 2017

Yes the issue is what @ahaverty described.

When you do this:

createThumbnail(1, ...);
createThumbnail(2, ...);
createThumbnail(3, ...);
...
return;

You are starting 3 asynchronous processes but you are returning right away. Therefore the instance gets shut down and your 3 createThumbnail don;t have time to complete.

Each of these returns a Promise. What you need to do is this instead:

const listOfAsyncJobs = [];
listOfAsyncJobs.push(createThumbnail(1, ...));
listOfAsyncJobs.push(createThumbnail(2, ...));
listOfAsyncJobs.push(createThumbnail(3, ...));
...
return Promise.all(listOfAsyncJobs); // This will ensure we wait for the end of the three aync tasks above.
2reactions
ValentinTalebcommented, Mar 22, 2017

Thanks a lot. You have saved my day !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: read ECONNRESET when resizing image with Firebase ...
I'd like to resize an image stored in Firebase Storage with Firebase Functions. Based on this example provided by the Firebase team :...
Read more >
read ECONNRESET when working with large data in Firebase ...
Coding example for the question Error: read ECONNRESET when working with large data in Firebase Cloud functions-node.js.
Read more >
Fixing an ECONNRESET error - Postman
The ECONRESET error means that the server unexpectedly closed the connection and the request to the server was not fulfilled. Connection-related ...
Read more >
Supabase Storage v2: Image resizing and Smart CDN
Today we're introducing three new features for Supabase Storage: Image resizing, webhooks, and a Smart CDN. These features are designed to ...
Read more >
azure-sql-database - Microsoft Q&A - Microsoft Learn
ConnectionError: Connection lost - read ECONNRESET (Node.JS Error) · azure-sql-database ... Read scale-out is giving the error "Execution Timeout Expired.".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found