barbajs Status Code: 500 Cannot read property 'action' of undefined

Created on 19 Nov 2019  Â·  8Comments  Â·  Source: barbajs/barba

Salaam

Barba is working fine I am using barba [email protected]. But On Status Code: 500 from server I am getting error

Cannot read property 'action' of undefined
at n.i.getAction

enter image description here

This is my code

barba.init({

    requestError: (trigger, action, url, response) => {
        debugger
        // go to a custom 404 page if the user click on a link that return a 404 response status
        if (action === 'click' && response.status && response.status === 404) {
            barba.go('/404');
        }

        // prevent Barba from redirecting the user to the requested URL
        // this is equivalent to e.preventDefault()
        return false;
    },

    cacheIgnore: true,
    prefetchIgnore: true,
    timeout: 30000,
    transitions: [
        {
            //sync: true,
            // css classes will look like `.fade-xxx-[-xxx]`
            name: 'fade',
            before({ current, next, trigger }) {



            },
            leave({ current, next, trigger }) {



            },
            afterLeave({ current, next, trigger }) {


            },
            beforeEnter({ current, next, trigger }) {


            },
            enter({ current, next, trigger }) {

            },
            after({ current, next, trigger }) {


            }
        }
    ]
})

This is the code I am using to Initialize. On 500 error code from server code runs till afterleave but does not run after the exception I have mentioned earlier.

@barbcore bug v2

All 8 comments

Hi @alijamal14,

500 error codes are related to server side. Can you access the web page https://localhost:44370/.../SaleTokenBill directly in the browser address bar and share what the console return?

Thanks :wink:

@xavierfoucrier Thank you,
Actually I deliberately generated internal server error to handle all internal server errors for client at run time.

I want to handle error code 500 but I am not able to handle my url https://localhost:44370/.../SaleTokenBill

gives error response in html when used on browser but with barba i am not able to handle it I have tried using requestError but still I am not able to handle it let me show you In a video

Video

You can check out the video here

Hi @alijamal14,

How do you trigger the error?
Programmatically, click, hover, prefetch?
Thanks

@thierrymichel it's probably triggered server-side because Barba action seems to be undefined.

@alijamal14 can you try to check for response.status before trying to access action, using something like this:

requestError: (trigger, action, url, response) => {
  console.dir(response);
  // ...
}

Mmmmh, it could also be related to the cacheIgnore option...

@thierrymichel it's probably triggered server-side because Barba action seems to be undefined.

@alijamal14 can you try to check for response.status before trying to access action, using something like this:

requestError: (trigger, action, url, response) => {
  console.dir(response);
  // ...
}

Thank You @xavierfoucrier but i have tried requestError but it's function's debugger wont hit at all. I could have done some handling if requestError would have hit.

Just for adding information before this error arise last line of execution where i can debug is leave function of barba. After this error arise the code breaks and we can't go to next state function afterLeave. Hope you understand what I am saying?

Good ca(t)ch(e) @thierrymichel!

I have just tested to access a HTTP 500 url in my local web server and I can confirm that using cacheIgnore option set to true will literally ignore the requestError method.

action here is undefined:
https://github.com/barbajs/barba/blob/f5e639ced58c559126ead53703c0cd46b047d366/packages/core/src/modules/Cache.ts#L64

@alijamal14,

It should be fixed in 2.9.4.
And it would be very appreciated if you could check and confirm… 😊

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shanewmurphy picture shanewmurphy  Â·  3Comments

3oax picture 3oax  Â·  4Comments

S1SYPHOS picture S1SYPHOS  Â·  3Comments

pburdylo picture pburdylo  Â·  3Comments

hosxes picture hosxes  Â·  3Comments