Kuan

January 17, 2023

Silly me. Listen to the (Dart) Stream.

I was working on some form submission feature in the noon. Things were going well. I cleaned up the code and commit them before my dinner break. There are a few latest changes from the remote need merging prior to continuing my work later.

Ate my food and wash everyone plates. I back at my desk to work. Rebuild, just to be sure. Then do a round of test on the form I were working on earlier. 

Hmm... Nothing happen after I click on the submit button. No HTTP requested, no print, no error. The clicks went into limbo.

"Sure as hell, it was working before". Said by every programmer, at least once in their lifetime.

The StreamController isn't initiated correctly? But I never change the name of the Constructor.

It didn't fire? But it did before, and all codes pointed to a correct pattern: click > send event > stream > map > flatmap > handleError.

Damn, must be some obscure random build bug, can't believe Google engineering team make such mistake, let me just rebuild from scratch to clean up the bad state. Clean, rebuild, same shit. Oops.

Statistically speaking, and I have more than a decade of programming data to drew on, 99.9% it was my fault. This time too.

The problem is "clean up and commit". Not all "clean" up is safe clean up. I cleverly remove the `listen()` section of the Stream. It wasn't doing anything before, just printing an "ok". I will add a redirection to it later and let's just keep all the `map`, `flatMap` and `handleError`. 

Well. The lesson today: If you never `.listen()` to the Stream, it will never run your transformers, only. Stream need at least one listener to trigger the even propagation.

Silly me.

About Kuan

Web developer building with Flutter, Svelte and JavaScript. Recently fell in love with functional programming.

Malaysian. Proud Sabahan. Ex game developer but still like playing games.

New found hobby is outdoor camping with my love.