@@ -2,9 +2,9 @@ const Raven = require("raven-js");
22const createRavenMiddleware = require ( "./index" ) ;
33const { createStore, applyMiddleware } = require ( "redux" ) ;
44
5- Raven . config ( "https://5d5bf17b1bed4afc9103b5a09634775e@sentry.io/146969" , {
6- allowDuplicates : true
7- } ) . install ( ) ;
5+ Raven . config (
6+ "https://5d5bf17b1bed4afc9103b5a09634775e@sentry.io/146969"
7+ ) . install ( ) ;
88
99const reducer = ( previousState = { value : 0 } , action ) => {
1010 switch ( action . type ) {
@@ -32,7 +32,7 @@ describe("raven-for-redux", () => {
3232 Raven . setDataCallback ( undefined ) ;
3333 Raven . setBreadcrumbCallback ( undefined ) ;
3434 Raven . setUserContext ( undefined ) ;
35-
35+ Raven . _globalOptions . allowDuplicates = true ;
3636 Raven . _breadcrumbs = [ ] ;
3737 Raven . _globalContext = { } ;
3838 } ) ;
@@ -186,6 +186,32 @@ describe("raven-for-redux", () => {
186186 userData
187187 ) ;
188188 } ) ;
189+
190+ [ "captureException" , "captureMessage" ] . forEach ( fnName => {
191+ it ( `retries ${ fnName } without any state if Sentry returns 413 request too large` , ( ) => {
192+ context . mockTransport . mockImplementationOnce ( options => {
193+ options . onError ( { request : { status : 413 } } ) ;
194+ } ) ;
195+ // allowDuplicates is set to true inside our handler and reset afterwards
196+ Raven . _globalOptions . allowDuplicates = null ;
197+ Raven [ fnName ] . call ( Raven , new Error ( "Crash!" ) ) ;
198+
199+ // Ensure transport and allowDuplicates have been reset
200+ expect ( Raven . _globalOptions . transport ) . toEqual ( context . mockTransport ) ;
201+ expect ( Raven . _globalOptions . allowDuplicates ) . toEqual ( null ) ;
202+ expect ( context . mockTransport ) . toHaveBeenCalledTimes ( 2 ) ;
203+ const { extra } = context . mockTransport . mock . calls [ 0 ] [ 0 ] . data ;
204+ expect ( extra ) . toMatchObject ( {
205+ state : { value : 0 } ,
206+ lastAction : undefined
207+ } ) ;
208+ const { extra : extra2 } = context . mockTransport . mock . calls [ 1 ] [ 0 ] . data ;
209+ expect ( extra2 ) . toMatchObject ( {
210+ state : "Failed to submit state to Sentry: 413 request too large." ,
211+ lastAction : undefined
212+ } ) ;
213+ } ) ;
214+ } ) ;
189215 } ) ;
190216 describe ( "with all the options enabled" , ( ) => {
191217 beforeEach ( ( ) => {
0 commit comments