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.

Uppy doesn't propogate Cross-Origin error

See original GitHub issue

If I try and use a S3-presigned-URL to PUT a file and the CORS configuration is not correct, i.e. PUT isn’t allowed, no appropriate error message is sent to the upload-error callback. This means I can’t let the user know what went wrong.

E.g.

this._uppy.on('upload-error', this._uppyError);

private readonly _uppyError: Function = (_file: any, error: Error, response: any) => {
    // response is undefined
    // error contains the text 'Upload error'
};

These values were sent by the error Event-Handler:

var error = buildResponseError(xhr, opts.getResponseError(xhr.responseText, xhr));

_this3.uppy.emit('upload-error', file, error);

xhr is:

mozAnon: false
mozSystem: false
onabort: null
onerror: null
onload: null
onloadend: null
onloadstart: null
onprogress: null
onreadystatechange: null
ontimeout: null
readyState: 4
response: ""
responseText: ""
responseType: "text"
responseURL: ""
status: 0
statusText: ""
timeout: 0
upload: XMLHttpRequestUpload
withCredentials: false

In the logs I receive the following two error messages:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://s3.eu-central-1.amazonaws.com/[omitted]. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://s3.eu-central-1.amazonaws.com/[omitted]. (Reason: CORS request did not succeed).

As far as I can tell, this doesn’t work as it should, but maybe there is an alternative way of getting at the error?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
Drucklescommented, Aug 11, 2020

It might have taken a while, but I’ve confirmed that this now works: we can ignore the request object and simply read out what’s in error.message, if it’s present, which is:

This looks like a network error, the endpoint might be blocked by an internet provider or a firewall. Source error: [Error: Upload error]

As that’s all we can get from the browser, it’ll have to do and if necessary we can check in the client’s browser logs 😃

2reactions
Drucklescommented, May 4, 2020

Ah, that’s great. We don’t have the latest version yet so I’ll have a check to see if that’s any better. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

A cross-origin error was thrown. React doesn't have access to ...
Frequently I too get this error, to solve this error 1. Open Dev tools 2. Go to Application section 3. Clear the local...
Read more >
CORS and Recipes - Beginner JavaScript - Wes Bos
In this video we are going to build an app that searches for a recipe based on a keyword and then we will...
Read more >
Troubleshooting - Datadog Docs
Troubleshooting. If you experience unexpected behavior with Datadog Browser RUM, use this guide to resolve issues quickly. If you continue to have trouble, ......
Read more >
Troubleshoot CORS errors from API Gateway - AWS
Cross-Origin Resource Sharing (CORS) errors occur when a server doesn't return the HTTP headers required by the CORS standard.
Read more >
Web on Reactive Stack - Spring
It is fully non-blocking, supports Reactive Streams back pressure, and runs on ... Spring WebFlux provides fine-grained support for CORS ...
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