Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

If Sentry responds with 413 request too large, try to send the exception again without any state#95

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ndbroadbent wants to merge2 commits intocaptbaritone:master
base:master
Choose a base branch
Loading
fromDocSpring:retry-request-too-large

Conversation

@ndbroadbent
Copy link

@ndbroadbentndbroadbent commentedOct 13, 2018
edited
Loading

Related:#42

This change ensures that all exceptions are reported, even if they don't include any state. In my own app, I'm also going to add some logic that removes the redux-undo state and only sends the current state.

Another solution would be to use thepako library to gzip the whole request, then send the data with aContent-Encoding: gzip header. Apparently some other Sentry clients do this, and since my state had a ton of repeated data due to the undo history, I was able to compress 220 KB down to 5 KB. I'm going to try this next and see if Sentry will accept the request.

Actually, I just realized that it would be much better to just intercept the request before it is sent, and check that the request body length is less than 204800. I think that would be a better idea - We can just dostringify(opts.data) in the transport and check the length. I'm just not sure if the "maximum payload size" of 200kB also includes request headers. For my test requests, the headers added 527B. So it might be good to give a few KB of leeway and just set the limit at 200000. And even if we detect the limit and bail out early, I think it's still a good idea to keep the retry logic for the 413 response, because it might change in the future.

Anyway, I'm going to keep working on this, but wanted to submit now to get some feedback. Thanks!

@codecov-io
Copy link

codecov-io commentedOct 13, 2018
edited
Loading

Codecov Report

Merging#95 intomaster willnot change coverage.
The diff coverage is100%.

Impacted file tree graph

@@          Coverage Diff          @@##           master    #95   +/-   ##=====================================  Coverage     100%   100%           =====================================  Files           1      1             Lines          26     58   +32       Branches       10     13    +3     =====================================+ Hits           26     58   +32
Impacted FilesCoverage Δ
index.js100% <100%> (ø)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update0ab4e52...e101118. Read thecomment docs.

@ndbroadbent
Copy link
Author

ndbroadbent commentedOct 13, 2018
edited
Loading

I've updated this PR with the 200kB check, so that we skip the initial request and just send the error without any state. But I decided it would be a good idea to still hande the 413 error and retry the request, because it was only a few extra lines of code.

Unfortunately there was no way to access thejson-stringify-safe code thatraven-js is using, because they include a vendored copy with some changes in the repo. I also couldn't find any way to intercept the stringified data before it was sent. So I ended up copying that same file intoraven-for-redux. It's only 76 lines of code, so not too important. (And felt a lot better than overridingfetch(),XMLHttpRequest, andXDomainRequest.)

@ndbroadbent
Copy link
Author

ndbroadbent commentedOct 14, 2018
edited
Loading

Unfortunately, zlib compression withpako was a dead end. But I finishedsome proof-of-concept code to test it out.

It was actually very easy to get the code working, and the only issue is that Sentry refuses theContent-Encoding header during the CORS preflight request.

They probably just don't support gzip/deflate for browser requests. But it's a bit weird, because most of their backend API clients seem to send error reports with gzip compression. And also, I don't think this will even solve the underlying issue. Even after decompressing the data, they will probably still check to make sure it's under 200KB.I've also posted about this on the Sentry forums.

In the end, I've just removed thepast andfuture keys added byredux-undo (as a stateTransformer in my own code), and now my state is always under 200KB (including breadcrumbs.) I was thinking about sending the history to my own server and storing it in my own database, but I realized that it's not actually that useful. I usually only need the latest state, action, and breadcrumbs to see why something crashed.

This might be controversial, but I think it would be great if the default stateTransformer did a quick check for anyredux-undo history and automatically removed it, because that was the main source of my problem. Thepast andpresent arrays include full copies of the state whenever a user makes a change. It's not a problem in the browser because they share the same memory references, but it's a huge problem when you need to serialize that data. This library is already specific toredux, andredux-undo is the most common way of adding undo/redo functionality to a React/Redux application. So maybe this makes sense as a good default. Otherwise mostredux-undo users will end up with 413 responses, or no state at all (when using the code in this PR.)

I might send another PR for this idea, as a proof of concept.

@ndbroadbent
Copy link
Author

ndbroadbent commentedOct 14, 2018
edited
Loading

Opened the PR to remove redux-undo history:#96

Even if you decide not to merge this, hopefully some people can find this and useremoveReduxUndoHistoryFromState as theirstateTransformer. Or maybe it would be a good addition to the README / Wiki.

@schrizsz
Copy link

+1 when is this planned to be merged?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@ndbroadbent@codecov-io@schrizsz

[8]ページ先頭

©2009-2025 Movatter.jp