Bloc: Bloc Dispatch Stops Working Once API returns an Error

Created on 26 Feb 2019  路  7Comments  路  Source: felangel/bloc

Describe the bug
Bloc does not dispatch event once the API Client returns an error. When dispatch method is called no error is reported and mapState is never fired

Git URL https://github.com/adewaleafolabi/portfolio

question

Most helpful comment

This helps running webdev serve with the release flag does work. I'd raise this issue with dartdevc Thank you

All 7 comments

@adewaleafolabi I took a look and I'm not sure how to reproduce the issue you're having. Can you please give more detailed steps for how to reproduce the issue?

I was able to force an exception and the bloc seems to be working fine.
screen shot 2019-02-26 at 6 21 32 pm

To reproduce the error:
I supplied a wrong password, the API then returns a 401. Clicking on the login button again is supposed to dispatch a login event, but this time no request to the API is made, no call to mapEventState is called either. Thank you

@adewaleafolabi ah so I wasn鈥檛 supposed to use the mock backend?

@felangel I've added a screen cast to show the error, also I've modified the mock_api to return a 401 on login. The event doesn't fire the second time after the first error.

capturebf02b81a4ea90898.gif

@adewaleafolabi I was able to reproduce this only when running in debug mode (webdev serve) however running in release mode (webdev serve --release) behaves as expected.

Looks like the problem is somewhere in dartdevc because by default, webdev serve compiles your app using dartdevc and adding the --release flag uses dart2js.

I would recommend opening an issue for dartdevc because I was also able to confirm that I if take your bloc and run it in a pure dart setting it works as expected.

You can see for yourself by copying this gist and running it using dart ./main.dart

Let me know if that helps! 馃憤

This helps running webdev serve with the release flag does work. I'd raise this issue with dartdevc Thank you

Same here, after fail API, mapEventToState not even called.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

komapeb picture komapeb  路  3Comments

MahdiPishguy picture MahdiPishguy  路  3Comments

RobPFarley picture RobPFarley  路  3Comments

Reidond picture Reidond  路  3Comments

shawnchan2014 picture shawnchan2014  路  3Comments