-
Notifications
You must be signed in to change notification settings - Fork 2k
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
When I upload a file with a larger size than the backend allows I don't get a 413 error #4253
Comments
Hi! Perhaps you can try to use |
Interesting, so you do see the correct status code and error in the network tab but not from Uppy in the console? |
Nope. When the upload fails for 413 (payload too large) I don't see the status code in the network tab (which I need to return proper message to the user) but I do see the status code if I try the same request with postman or similar tools. |
Do you see any CORS error in your browser? The error message
Not sure why a 413 would cause that but I know that if CORS fails, it will not return the proper 413 status code to the JS code. |
No CORS issue at all, trust me. The call goes to the backend, in the requested handler (CORS would stop everything much earlier). And even if it was CORS (which it isn't) the browser should tell. |
Can you confirm the response headers with the 413 status response also contains CORS headers? Could you paste the exact response headers from chrome devtools? what about if you right click the request in chrome devtools, then «copy as curl», then add |
If you have a minimal reproduceable code, like a simple express server that responds with 413 and triggers this error also on my machine, then we have something more to work with. Or you can share your server url if hosted somewhere |
I tried this now: const http = require('http');
const server = http.createServer((req, res) => {
if (req.method === 'OPTIONS') {
res.writeHead(200, { 'Access-Control-Allow-Origin': '*' });
res.end();
return;
}
if (req.method === 'POST') {
res.writeHead(413);
// res.writeHead(413, { 'Access-Control-Allow-Origin': '*' });
res.end();
return;
}
res.writeHead(400);
res.end();
return;
});
server.listen(8080); It gives:
If I instead comment out this line // res.writeHead(413); and uncomment this: res.writeHead(413, { 'Access-Control-Allow-Origin': '*' }); ...then I don't get the error anymore ( |
So the same as mine? I cannot share a server/code right now. But your express code looks the same. Is not a CORS error. |
Can you reproduce the issue with my code? |
Sorry for the late answer. I tried with your code and it's the same, @mifi. |
If I use insomnia on my PC it gets the 413 status code error, Uppy doesn't.
|
ok, if you can share some code to reproduce the problem, then we could look into it |
I created https://github.com/frederikhors/iss-uppy-413 for you. This is an exactly reproduction of the issue. Steps:
As you can see here there is no CORS involved at all. |
@mifi, thanks for your answer. I created the reproduction because if I use the same Rust code with Postman the 413 is visible in the response (se previous post), so I still think the problem is in Uppy.
Why? Can you tell me how can I help you make it work? Did you try to make it start on codesandbox? |
Yes, the code is a little bit different on this reproduction, but it's the same.
Maybe you should fork the project on codesandbox? I believe if you don't fork it it's just read-only. |
I cannot find any fork button |
|
seems i need to have a codesandbox account to do that. could you try to run a simple |
Yeah, as I said I already did and it works: I get the 413. Only with uppy not. I tried again with curl, using:
and I get:
Do you see the |
could you run a public server that responds with 413 and reproduces the problem and share the URL? maybe the problem is specific to XMLHTTPRequest (which uppy uses) |
I shared the codesandbox and the GitHub repo. Can you run a docker container with that GitHub repo? And, please, can you reopen this issue? I'm afraid it can go lost... |
Ok sure, how do i run this in docker? I cannot find the dockerfile |
The Dockerfile is not in the repo, but this should work: FROM rust:1.75
COPY ./ ./
RUN cargo build
CMD ["./target/debug/iss-uppy-413"] |
does it work for you? doesn't seem to work here: [+] Building 3.7s (7/7) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 118B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/rust:1.75 3.4s
=> [internal] load build context 0.0s
=> => transferring context: 2B 0.0s
=> [1/3] FROM docker.io/library/rust:1.75@sha256:ac8c4cb82e317512260fbcf54e80039d9083605e3b8ea3b9fd4c39e147 0.0s
=> CACHED [2/3] COPY ./ ./ 0.0s
=> ERROR [3/3] RUN cargo build 0.3s
------
> [3/3] RUN cargo build:
0.260 error: could not find `Cargo.toml` in `/` or any parent directory
------
Dockerfile:5
--------------------
3 | COPY ./ ./
4 |
5 | >>> RUN cargo build
6 |
7 | CMD ["./target/debug/iss-uppy-413"]
--------------------
ERROR: failed to solve: process "/bin/sh -c cargo build" did not complete successfully: exit code: 101 even though Cargo.toml exists in the current directory |
Yeah. It works. I tried just now. I updated Readme, added Dockerfile and changed this: frederikhors/iss-uppy-413@5846a06. |
I'm on Version 120.0.6099.234 (Official Build) (arm64). Does it happen in other browsers too? I don't know how to reproduce your issue unfortunately |
I know you have to reduce open issues, but I think this is still a problem (even the fact that you cannot reproduce but I can). Can you please re-open until we understand why? |
could you run a server with a public URL that responds with 413 in a way that reproduces this issue? Because with your dockerfile i cannot reproduce it |
Okay. A moment to recap. The problem is that on Windows PC and Chrome 120 and Firefox 122 I don't get the code 413 from server using Uppy. That is, I cannot know the precise cause of the upload failure. I don't think the public server is necessary because the Dockerfile serves precisely to have an objective way of launching software. And when we both launch this software and open localhost:3000 we each have a different result when uploading files larger than 1 MB in size. Can you tell me what operating system and version of Chrome you are trying with? Can you try Firefox? Or Safari? |
I shared the version, and im on macos sonoma. I tried safari and it was the same. I cannot reproduce the problem with the docker image so i dont know what else to try, that’s why i thought that if you have a server running that reproduces the problem, i could try to use that too. |
But if I publish a server is the same of the Dockerfile one. Can you try with a Windows PC? |
Ok. Thanks. I'm happy now! Not because of the issue of course! 😆 |
I tried to run this code: const http = require('http');
const html = `\
<!doctype html>
<html>
<head>
<link href="https://releases.transloadit.com/uppy/v3.21.0/uppy.min.css" rel="stylesheet">
</head>
<body>
<div id="uppy"></div>
<br><br>
<form action="/" method="post" enctype="multipart/form-data">
<label>
Upload file:
<input type="file" name="file" multiple>
</label>
<input type="submit" value="Upload files">
</form>
<script type="module">
import { Uppy, XHRUpload, Dashboard } from "https://releases.transloadit.com/uppy/v3.21.0/uppy.min.mjs"
const uppy = new Uppy()
.use(XHRUpload, {
endpoint: "/",
bundle: true
})
.on('upload-success', (info) => {
console.log("upload-success, info:", info);
});
uppy.use(Dashboard, { target: '#uppy', inline: true })
</script>
</body>
</html>`
const server = http.createServer((req, res) => {
if (req.method === 'POST') {
res.writeHead(413);
res.end();
return;
}
if (req.method === 'GET' && req.url === '/') {
res.setHeader('content-type', 'text/html');
res.write(html)
res.end();
return;
}
res.writeHead(400);
res.end();
return;
});
server.listen(8080); but i cannot reproduce the problem on windows (i'm getting 413 correctly), so I think the problem exists on Windows (browser) and Rust htttp server (probably |
I'm using the following code, but when I upload a file with a larger size than the backend allows, I don't get a 413 error (which I get instead by using Postman for the same call).
This is the dev tools:
There are no Response Headers in request.
I only get a generic:
Is this my fault?
The text was updated successfully, but these errors were encountered: