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.

Thumbnails example - ECONNRESET

See original GitHub issue

Hello,

I developed something really close to Thumbnails example provided here, and sometimes (often) I’m getting this error when uploading or deleting files from Storage :

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

I found #78, but I checked that a promise is returned everytime. Here is some code snippet, for the deletion part :

index.js

exports.exampleFunction = functions.storage.object().onChange(event => {
    return f_thumbnails.exampleFunction(event);
});

example_function.js

module.exports = exports = function (_admin, _config) {
    admin = _admin;
    config = _config;

    return {
        "exampleFunction": function (event) {
            return exampleFunction(event);
        }
    };
};

const exampleFunction = function (event) {
    const gcsSourceFilePath = event.data.name;
    const gcsSourceFilePathSplit = gcsSourceFilePath.split('/');
    const gcsBaseFolder = gcsSourceFilePathSplit.length > 0 ? gcsSourceFilePathSplit[0] : '';
    const gcsSourceFileName = gcsSourceFilePathSplit.pop();
    const gceSourceFileDir = gcsSourceFilePathSplit.join('/') + (gcsSourceFilePathSplit.length > 0 ? '/' : '');

    // Not an image
    if (!event.data.contentType.startsWith('image/')) {
        console.log('Not an image !');
        return;
    }

    // Thumbnail
    if (gcsSourceFileName.startsWith(config.IMAGES_THUMBNAIL_PREFIX)) {
        console.log('Thumbnail !');
        return;
    }

    const bucket = gcs.bucket(event.data.bucket);
    const gcsThumbnailFilePath = gceSourceFileDir + config.IMAGES_THUMBNAIL_PREFIX + gcsSourceFileName;


    // File deletion
    if (event.data.resourceState === 'not_exists') {
        console.log('Thumbnail deletion : ' + gcsThumbnailFilePath);
        return bucket.file(gcsThumbnailFilePath).delete().then(() => {
            console.log('Deleted thumbnail ' + gcsThumbnailFilePath);
        });
    }
    ...

I also created this StackOverflow post.

Thanks.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mrp14commented, Apr 27, 2017

Someone on SO linked this : https://issuetracker.google.com/issues/36667671 Visibly we just have to wait for a new release of google-cloud-node, or use this patch

If someone can confirm this is working (can’t try this out today)

1reaction
inlinedcommented, Apr 25, 2017

I think the ECONNRESET issue is an issue in the google-cloud-node module and have filed https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2254 to escalate.

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 >
GoogleChrome/lighthouse - Gitter
Hi all, I'm wondering if there is a way in the latest Lighthouse to configure the order of custom audit/gatherer. In my case...
Read more >
Securing Ingress and Egress - Red Hat | Public Sector
In this example we are going to restrict access to external endpoints to only approved hosts. The service mesh has an egress router...
Read more >
Node.js Express: JWT example | Token Based Authentication ...
In this tutorial, we're gonna build a Node.js Express Rest API example that supports Token Based Authentication with JWT (JSONWebToken).
Read more >
[NODE-719] Connection leaking and authentication issues
... some trouble getting the new pre-release working. I've updated the example script a tiny bit: ... Error: read ECONNRESET. at exports.
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