SPOILER ALERT: Do not read if you have not yet watched “Chapter Fifty-Eight: In Memoriam,” the fourth season premiere of “Riverdale.”

The titular town of the CW’s “Riverdale” is down one more beloved member in Fred Andrews (Luke Perry), who was officially written out of the show in the fourth season premiere, aptly titled “In Memoriam.”

Picking up months after the events of the third season finale — months that Jughead’s (Cole Sprouse) narration claimed to have been quiet — the first inciting incident back was not a reveal of why central characters Archie (KJ Apa), Betty (Lili Reinhart) and Veronica (Camila Mendes) were burning Jughead’s beanie in the woods in the third-season flash-forward ending, but rather that Fred had been killed.

While planning a July 4th parade and additional camping trip with his friends, Archie got a call from his father’s phone — only it wasn’t Fred on the other end. He dropped to his knees out of sheer emotion and later learned from new sheriff FP (Skeet Ulrich) that Fred pulled over to help someone stalled on the side of the road and got hit by a car. As Archie took the news in somewhat stoically, his mom Mary (Molly Ringwald) broke down in tears, and the family dog Vegas sat by the door, still waiting for Fred to return home.

After learning it was a hit-and-run, Archie was dead-set on finding out who did it, only for FP to tell him he would make sure it would be taken care of. Now, as Archie soon learned, it would be about taking over that aforementioned nationally patriotic celebration to say goodbye to the Andrews patriarch.

The characters spent time sitting around and reminiscing about Fred being influential on their formative years, from building treehouses, to taking care of FP when he was drunk, to stepping in as a father figure for Betty during a father-daughter potato sack race and working on sets for the school’s musicals.

But, in true “Riverdale” form, no character’s death could be completely straight-forward. During a dream, Archie’s grandfather asked him about his father, to which Archie replied, “I thought he was already with you.” Archie awakened from the dream determined to bring Fred home.

Borrowing a hearse from Reggie (Charles Melton), Archie and his friends took a roadtrip. Once upstate, Archie learned where the site of the hit-and-run was but couldn’t bring himself to identify his father’s body, so Betty and Veronica stepped up. Archie also asked Jughead to write Fred’s obituary for the town’s newspaper.

Archie went to the site and found his dad’s truck — as well as the woman Fred had stopped to help the night he was killed (played by special guest star Shannen Doherty). She arrived to leave flowers, but she ended up telling Archie how no one would stop to help her because cars were “whizzing by.” But Fred did — and he didn’t stop talking about his son the whole time they were trying to fix her tire. When the car sped towards them, she froze, but Fred pushed her out of the way, saving her life.

“He died a hero,” Veronica told him.

“He died on the side of the road, without an ambulence, without his friends,” Archie countered. “That’s not heroic; that’s senseless.”

The episode was an extra emotional one for the “Riverdale” cast and crew, as Fred was only written out of the show out of necessity: Perry passed away on Mar. 4 of this year, from complications after having a stroke. The third season of “Riverdale” was still in production at the time and addressed the actor’s passing with an In Memoriam card tacked onto the end of the Mar. 6 episode. Perry’s final scene aired on April 24. As the show inched toward its season finale, showrunner Roberto Aguirre-Sacasa opted not to permanently write Perry out just yet.

“That was a decision we made partly because when Luke passed it was such a shock, and we were so sad — we were so bereft — and we knew we had to address it some way, but we didn’t want to get it wrong,” he told Variety at the time.

Months later, though, Aguirre-Sacasa and his writers’ room were able to reconvene with some distance from the initial shock over Perry’s passing to put together a story that allowed the cast to grieve on-screen.

In many ways, some of what the characters spoke of when they remembered Fred may have been memories of Perry, too. Apa has been open in the past about how close he and Perry became during shooting, and Archie acknowledged that his dad “taught him everything” and spoke of how it killed him that he won’t get to see him again but that his “spirit lives on” in everyone he met. Similarly, Veronica expressed how proud of Archie Fred was of him, a sentiment Perry often personally expressed when talking about how he felt, working nwith the younger generation of actors on this show.

And the sense of loss felt by Perry’s absence certainly seemed to loom over scenes in which Archie talked about his father’s death being senseless, and then vowing to get revenge on the guy who killed him.

But when Archie showed up at the guy who confessed’s house, he learned it was actually that guy’s teenage son that did it — taking the care when he didn’t even have a license. This caught Archie off-guard — because it was something he could have imagined happening to him, and his father would have protected him the same way.

On the way back to their hometown, FP stopped the hearse in the middle of the road, offering to provide a police escort the rest of the way. As they made their way into the center of town, the sidewalks were filled with civilians waving American flags and holding signs that said, “Welcome home, Fred.” It may not have been the parade they were expecting when they started prepping for the fourth of July, but it was a more-than-memorable one nonetheless.

Even Hiram (Mark Consuelos) paid his respects from prison — literally paying the bill for Fred’s funeral.

That service included Ashleigh Murray singing “Amazing Grace” and the male characters carrying the coffin. Through tears, Archie gave a eulogy that spoke of how Fred helped build this town and segued into a memory about a previous July 4th when the town’s fireworks were canceled due to inclimate weather so Fred brought some home to light in the backyard. After the funeral, the gang gathered in the same backyard with sparklers and fireworks to celebrate the man who Jughead wrote in that obituary, “was our good samaritan, our George Bailey, our knight in flannel armor.”

The episode ended with Archie reminiscing about working with his father on the jalopy inside their garage. The show included a couple of flashbacks that included Perry in them before fading to an “In loving memory, Luke Perry 1966-2019” card.

“Imagine if everyone was even half as good as my dad was,” Archie said. “I’m going to honor him. I’m going to honor his memory every day.”

“Riverdale” airs Wednesdays at 8 p.m. on the CW.