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

undefined is not a function (near '...Promise.allSettled...') #3533

Open
Zimmee opened this issue Mar 4, 2022 · 5 comments
Open

undefined is not a function (near '...Promise.allSettled...') #3533

Zimmee opened this issue Mar 4, 2022 · 5 comments

Comments

@Zimmee
Copy link

Zimmee commented Mar 4, 2022

I'm getting error when trying to upload file to Aws S3 in React Native
The error:

[Uppy] [16:22:35], undefined is not a function (near '...Promise.allSettled...')
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\@uppy\core\lib\loggers.js:12:5 in justErrorsLogger.error
at node_modules\@uppy\core\lib\Uppy.js:1221:4 in log
at node_modules\@uppy\core\lib\Uppy.js:1513:9 in _showOrLogErrorAndThrow2
at node_modules\@uppy\core\lib\Uppy.js:1349:6 in Promise.resolve.then._catch.then$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:123:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:177:14 in _callImmediatesPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:437:30 in callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:388:6 in __callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:132:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:131:4 in flushedQueue

The code were i initialize Uppy:

this.uppy = new Uppy({ autoProceed: true }).use(AwsS3, {
      companionUrl: '*my companion url*',
    });

And here is the part where i add file that i'm getting from expo-image-picker:

 this.uppy.reset();
 const f: Blob = this.state.file;
 this.uppy.addFile({
    name: urlSplit[urlSplit.length - 1],
    type: f.type,
    data: f,
 });

I have React Native version="0.64.3" and Expo version="~44.0.0",

@Murderlon
Copy link
Member

Unfortunately we currently don't have a lot of bandwidth for React Native. If you can pursue this issue further that would also be appreciated.

@giacomocerquone
Copy link
Contributor

giacomocerquone commented Oct 18, 2022

This is clearly because there was no support for Promise.allSettled in react-native until the very recent versions.
Would you insert a polyfill in here to support "older" versions of react native? @Murderlon

I'll create an expo snack by the way to test the compatibility of uppy with react-native. If everything works out, I'll do a pr to the docs showcasing the react-native support

@Murderlon
Copy link
Member

Would you insert a polyfill in here to support "older" versions of react native? @Murderlon

We're currently quite busy with other priorities, if you're willing to create a PR that would be great.

@giacomocerquone
Copy link
Contributor

yeah sure why not. Let me first try to make an expo sample app work and then I'll open a pull request with the necessary polyfills and whatnot 🙂

@Anjalipatil18
Copy link

loggers.js:40 [Uppy] [16:44:04] TypeError: Promise.allSettled is not a function
at _callee$ (index.js:187:58)
at tryCatch (index.js:1:1357)
at Generator. (index.js:1:4174)
at Generator.next (index.js:1:2208)
at asyncGeneratorStep (index.js:5:102)
at _next (index.js:6:194)
at index.js:6:364
at new ZoneAwarePromise (zone.js:931:1)
at index.js:6:97
at value (index.js:229:25)

Issue: When uploading files using Uppy and AWS S3, I encounter the following error messages: "Upload failed" and "Retry."
Description:
I'm building an application using Angular and integrating Uppy for file uploads to AWS S3.
The file upload process is initiated by the user, but it fails with the mentioned error messages.
Despite the error messages, the files seem to be successfully uploaded to the AWS S3 bucket.
Steps to reproduce:
Access the file upload feature in the application.
Select a file and initiate the upload process.
Observe the error messages "Upload failed" and "Retry."
Expected behavior:
The file should be uploaded successfully to the AWS S3 bucket without any error messages.
Actual behavior:
The file upload process displays error messages "Upload failed" and "Retry," even though the files are uploaded to the AWS S3 bucket.
Code:
I'm using Angular for the frontend, and here's the relevant code snippet for the file upload functionality:

uppyHandler() {
const token = localStorage.getItem('token');
const uppy = new Uppy.Uppy({ debug: true, autoProceed: false, restrictions: { maxNumberOfFiles: 1 } })
.use(Uppy.Dashboard, {
trigger: this.uppyContainer.nativeElement,
autoOpenFileEditor: true
})
.use(Uppy.ImageEditor, { target: Uppy.Dashboard })
.use(Uppy.AwsS3, {
getUploadParameters(file) {
const timestamp = new Date().getTime();
const fileNameWithTimestamp = ${timestamp}_${file.name};
return fetch(${devUrl}aws/presigneUrl, {
method: 'POST',
headers: {
authorization: token,
'Content-Type': 'application/json'
},
body: JSON.stringify({
fileName: fileNameWithTimestamp,
bucket: IMAGE_BUCKET,
folder: 'users/seo-setting'
})
}).then((response) => {
return response.json();
}).then((data) => {
if (data && data.message === 'Success' && data.data && data.data.presignUrl) {
return {
url: data.data.presignUrl,
method: 'PUT'
};
} else {
throw new Error('Invalid response format from server');
}
});
},
});

uppy.on('upload-success', (file, response) => {
  const url = response.uploadURL.replace(/^https:\/\/dev-bombshell-images\.s3\.amazonaws\.com/, '');
  const newUrl = url.trim();
  this.tiktokImages = newUrl;
  this.addForm.get('tiktokImages').setValue(newUrl);
});

uppy.on('complete', (result) => {
  if (result.successful.length > 0) {
    console.log('Upload complete! We’ve uploaded these files:', result.successful);
  } else {
    console.log('Upload error:', result.failed);
  }
});

}

Additional context:
The file uploads appear to be successful despite the error messages.
I'm using Angular with Uppy and AWS S3 for the file upload functionality.
can anyone send me solution of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants