mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
126 stars 41 forks source link

simulate-async-error seems to be broken locally #2079

Open bobsilverberg opened 4 years ago

bobsilverberg commented 4 years ago

While reviewing mozilla/addons-frontend#9122, I discovered that http://localhost:3000/en-US/firefox/simulate-async-error/ is broken. When I try to load that route, I get the "Webpack is still loading!" page and then the server stops responding. Here's what I see in the console:

[1] [1582564089207081700] INFO  (amo/48569 on bsilverberg29769): Replacing lang in URL en-US -> en-US
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089207500800] INFO  (amo/48569 on bsilverberg29769): Clearing require cache for webpack isomorphic tools. [Development Mode]
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089208250400] INFO  (amo/48569 on bsilverberg29769): Dispatching SET_REQUEST_ID
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089213352200] INFO  (amo/48569 on bsilverberg29769): Dispatching SET_AUTH_TOKEN
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089214636500] DEBUG (amo/48569 on bsilverberg29769): Encoding `apiURL` in UTF8 before fetch().
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089217308700] INFO  (amo/48569 on bsilverberg29769): Dispatching SET_LANG
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089219546600] INFO  (amo/48569 on bsilverberg29769): Dispatching SET_CLIENT_APP
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089219816700] INFO  (amo/48569 on bsilverberg29769): Dispatching SET_USER_AGENT
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089226326000] INFO  (amo/48569 on bsilverberg29769): Intl.NumberFormat exists
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089226656000] INFO  (amo/48569 on bsilverberg29769): First component render to dispatch loading actions
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089227530000] INFO  (amo/48569 on bsilverberg29769): Dispatching @@router/LOCATION_CHANGE
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089239653000] DEBUG (amo/48569 on bsilverberg29769): Generated error handler ID with extractId(): src/amo/components/AutoSearchInput/index.js-q
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089242946000] INFO  (amo/48569 on bsilverberg29769): Simulating an asynchronous error
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[1] [1582564089267928300] INFO  (amo/48569 on bsilverberg29769): Dispatching @@redux-saga/CHANNEL_END
[1]     amo_request_id: "3776046d-b087-4673-8c27-879ce81dc8cc"
[2] [1582564089529] DEBUG (amo.proxy/48475 on bsilverberg29769): 200 ~> https://addons-dev.allizom.org/api/v4/accounts/profile/?wrap_outgoing_links=true
[1] /Users/bsilverberg/Documents/gitRepos/addons-frontend/src/core/pages/error-simulation/SimulateAsyncError/index.js:57
[1]         throw new Error('This is a simulated asynchronous error');
[1]         ^
[1]
[1] Error: This is a simulated asynchronous error
[1]     at Timeout._onTimeout (/Users/bsilverberg/Documents/gitRepos/addons-frontend/src/core/pages/error-simulation/SimulateAsyncError/index.js:11:13)
[1]     at listOnTimeout (internal/timers.js:531:17)
[1]     at processTimers (internal/timers.js:475:7)
[2] [1582564089640] ERROR (amo.proxy/48475 on bsilverberg29769): ERR ~> http://127.0.0.1:3333/en-US/firefox/simulate-async-error/ Error: socket hang upThis problem exists on the current master, so it's not a result of that patch. It does, however, work on dev, so it seems to be a local-only issue. I have not dug into it any further, but wanted to report it.

┆Issue is synchronized with this Jira Task

mirefly commented 4 years ago

I investigated this issue a bit, and found that the simulated async error could not be caught by the Error boundaries, and finally brings down the frontend host server (localhost:3333). This same problem occurs in local, dev and stage as long as allowErrorSimulation is true.

STR:

  1. Go to https://addons.allizom.org/en-US/firefox/simulate-async-error/ (once or twice?)
  2. Then https://addons.allizom.org/en-US/firefox returns 504. I guess the server restarts in a while.

In order to catching the async error, we have to do a trick https://github.com/facebook/react/issues/14981#issuecomment-468460187 when throwing out the error. I am not sure if we would like to do it in our SimulateAsyncError, since the web still could not deal with other (unexpected) async errors which are not "wrapped" in setState.

@bobsilverberg Do we need to add something to handle async errors which occur in rendering on the server (maybe in core/server/base.js)? or any other suggestions? https://github.com/mozilla/addons-frontend/blob/d4f2cbae670f0ceb4e4fe93501aa1e31a0d82df3/src/core/server/base.js#L113

bobsilverberg commented 4 years ago

Would we ever have an async error when rendering on the server (except with this artificial one we create for testing purposes)? We don't actually render anything meaningful on the server, unlike in addons-frontend.

@willdurand WDYT, is this something we need to worry about?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this bug should stay open, please comment on the issue with further details. Thank you for your contributions.

KevinMind commented 5 months ago

Old Jira Ticket: https://mozilla-hub.atlassian.net/browse/ADDFRNT-173