Reaction: Upload images - Runtime error

Created on 18 Oct 2020  路  11Comments  路  Source: reactioncommerce/reaction

Issue Description

When I try to create products, or upload any image I receive an exception

https://gist.github.com/dzirg44/d16f5cc84087cae8c2a47b7568531db4

Steps to Reproduce

  1. update Development platform to the latest version
  2. enter to the Admin ui
  3. create product
  4. upload image

Possible Solution

https://github.com/reactioncommerce/reaction-file-collections/blob/master/packages/file-collections/src/common/FileCollection.js

Versions

latest docker image versions or use development platform.

bug

Most helpful comment

OK this is a deep maze to trace through, but so far my analysis is as follows:

  • In TempFileStoreWorker the fileRecord object is emitting an "error" event without passing an error. This is causing a long chain of code to fail ultimately failing the image resizing job.
  • I made a temporary hack to detect this bogus error event and disregard it instead of rejecting the promise at hand.
  • That seems to allow the upload to complete entirely
  • Digging further down the rabbit hole as to why the fileRecord is emitting an undefined error is next up

All 11 comments

getting the same issue on Ubuntu 20.04.1 LTS, and using the latest "reaction-development-platform" images as well.

same issue .. the admin is very buggy.. it was cool to have a powerful node js ecommerce solution. but it is still very buggy. admin not working and reaction-api keep crashing. unfortunately i have to ditch this project

Unfortunately, Reaction Commerce doesn't look alive after Mailchimp ate it. Hope, this wrong though.

I can reproduce this. Working on a fix.

Some debugging notes to self:

  • Most packages inside reaction-file-collections will not successfully package-link into reaction API unless you delete their "prepublishOnly" script from their package.json file
  • To link in your locally-modified code, do the following dance once reaction API is running:
cd ~/github.com/reactioncommerce/reaction-file-collections &&
cd packages/file-collections-sa-gridfs &&
npm run build &&
cd ~/github.com/reactioncommerce/reaction-development-platform/reaction &&
./bin/package-link @reactioncommerce/file-collections-sa-gridfs ../../reaction-file-collections/packages/file-collections-sa-gridfs

I'm attaching logs from reaction API with DEBUG=reaction* which provides good extra detail here. The upload is completing but the error seems to be happening during the first image resizing transformation.

reaction-6298-api.log

Please disregard that auto-close. It was based on github automatic rules that don't understand the word might.

OK so in @reactioncommerce/file-collections 0.9.2 which I just published, I reverted the tus-js-client back to ^1.5.1, and seems to have resolved at least one or two errors with image uploads. That dep got accidentally updated to 2.x during routine dependency updates for security issues. It's a semver breaking change though and we should not have updated beyond 1.x. There are still further issues I believe with displaying the media gallery and getting the URLs right so I'll continue to debug those.

The original upload is working and we are storing a URL in mongo that is correct and will be served correctly through the API server, but the URLs for the resized versions all appear to be "null" so looking into that to fix it.

OK I've found that the background jobs to resize images are also failing due to the same bug in the error handling in reaction-file-collections FileCollection.js here.

Lots of entries in the job failures like this:

        "failures" : [
                {
                        "value" : "Failed for exceeding worker set workTimeout",
                        "runId" : "3ifsPCimbEFELBNuu"
                },
                {
                        "value" : "Failed for exceeding worker set workTimeout",
                        "runId" : "fhqoaE9JikqXqBZsR"
                },
                {
                        "value" : "Failed for exceeding worker set workTimeout",
                        "runId" : "Xph4Kr8fKqo5CT3rp"
                },
                {
                        "value" : "Failed to convert temporary image from jyQSTH4CBxd2STchB. Error: TypeError: Cannot read property 'message' of undefined",
                        "runId" : "6M58XZHC3NmWuS3ww"
                },
                {
                        "value" : "Failed to convert temporary image from jyQSTH4CBxd2STchB. Error: TypeError: Cannot read property 'message' of undefined",
                        "runId" : "nFHCggTzXDHy6BbEh"
                },
                {
                        "value" : "Failed to convert temporary image from jyQSTH4CBxd2STchB. Error: TypeError: Cannot read property 'message' of undefined",
                        "runId" : "5yXsi5aNjgDH9Zuwj"
                }

OK this is a deep maze to trace through, but so far my analysis is as follows:

  • In TempFileStoreWorker the fileRecord object is emitting an "error" event without passing an error. This is causing a long chain of code to fail ultimately failing the image resizing job.
  • I made a temporary hack to detect this bogus error event and disregard it instead of rejecting the promise at hand.
  • That seems to allow the upload to complete entirely
  • Digging further down the rabbit hole as to why the fileRecord is emitting an undefined error is next up

Need to update dependencies to bring the fix into api-plugin-files and reaction API but running into ES Modules woes and sharp native add-on woes that may necessitate a new node-dev docker image. Onward...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

focusaurus picture focusaurus  路  4Comments

aaronjudd picture aaronjudd  路  3Comments

aldeed picture aldeed  路  4Comments

nnnnat picture nnnnat  路  4Comments

ajporlante picture ajporlante  路  4Comments