Comedy is hard. Just ask ABC. Or CBS, or NBC, or Fox.

The major networks have struggled mightily for a decade to field an unqualified sitcom smash. ABC’s reboot of “Roseanne” was that show — until it all fell apart with the touch of a “Send” button.

ABC took the extraordinary step of canceling “Roseanne” after star Roseanne Barr sent a racist tweet that likened Obama administration adviser Valerie Jarrett to an ape. Barr apologized for what she called a “joke,” but the damage was done. As outrage at the racial slur steamrolled online, ABC and parent company Disney were left with little choice but to sever ties with Barr. It all went down in a matter of hours as the industry was getting back to work after the Memorial Day holiday weekend.

The situation was unprecedented, and nothing less than traumatic for ABC insiders. “Roseanne” stunned as it rocketed out of the gate in March with some 22 million viewers. It stayed strong throughout the rest of its nine-episode run to end the 2017-18 season as primetime’s No. 1 show in the adults 18-49 demographic and total viewers: not just the No. 1 new show but the most-watched program in all of primetime — topping NBC’s “Sunday Night Football” and CBS’ “The Big Bang Theory.”

After the shock of the cancellation wore off, key producers behind the “Roseanne” revival — Tom Werner, Sara Gilbert (who also co-stars) and showrunner Bruce Helford — began the inevitable conversations about the possibility of salvaging the show without Barr’s participation. For instance, one option is that the show might be rebranded to focus on the character of Darlene, played by Gilbert. Part of the consideration for keeping the show alive is the fact that ABC and Carsey-Werner Co. are contractually bound to pay the actors and some writers for the season that was ordered whether or not it is produced.

In an ironic twist, the jolt of the cancellation came on the same day the show’s writers were scheduled to reconvene at offices on the CBS Studio Center lot to begin work on the next batch of 13 episodes. “Shell-shocked” was the description of the atmosphere among the writers who came to work that day expecting that the only strain they would face was to live up to the lofty standard set by the first season.

Another reason to try to save the show: ABC desperately needed the boost “Roseanne” delivered. The network has fallen behind its Big Four rivals and has had trouble launching successful series. Comedies have traditionally been highly prized because when they work, they tend to do so for a long time. “Big Bang” just wrapped its 11th season. “Roseanne” ran for nine seasons (1988-97) on ABC.

The revived “Roseanne” was also valuable to ABC because of the cultural conversation that it sparked. Barr’s blue-collar hero Roseanne Conner returned 20 years later as an avowed supporter of President Donald Trump, just as Barr is behind the scenes. In the tradition of “All in the Family,” the new-model “Roseanne” sought to examine hot-button issues that separate liberals and conservatives. This took the show from the entertainment pages to the front pages, making it seem emblematic of the oh-so-polarized Trump era. That’s the kind of promotion that no network can buy. But it’s also the kind of attention that made Barr’s comments impossible for ABC to dismiss with merely a slap on the wrist.

The rebooted series’ stunning debut, with more than 18 million viewers tuning in live, fueled a lot of soul-searching among Hollywood programming executives and creatives. Many saw it as a wake-up call to the industry that a multicamera show focused on meat-and-potatoes issues for a heartland family had greater resonance than any other comedic voices showcased in recent years. It also made creatives think aloud that the TV business has become too willing to accept ever-diminishing ratings as the inevitable byproduct of a fragmented media landscape.

“Roseanne” proved that broadcast TV can still draw a big crowd. The fishbowl world of social media ensures that noisy mobs will assemble with lightning speed if given the right ammunition. Barr’s indefensible, racially charged comment about an African-American woman was high-octane fuel for the outrage machine that drives so much of the national agenda these days.

Brash and bold, like its namesake star, “Roseanne” realized its potential and then some. For ABC and for the industry, that the show succeeded where so many others have failed of late only made its senseless loss that much harder to bear.