Thumbnails example - ECONNRESET
See original GitHub issueHello,
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:
- Created 6 years ago
- Comments:13 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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)
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.