About a year and a half ago, longtime patrons of the pioneering grocery delivery service FreshDirect started complaining that orders were arriving hours late. There were broken eggs and spoiled fruit. One customer reported that she had paid $200 for groceries — only to receive nothing but seltzer and a loaf of bread.

The source of the problems was FreshDirect’s multimillion-dollar headquarters in the Bronx, a distribution center with nine miles of conveyor belts that the company opened in the summer of 2018 after moving out of a smaller facility in the Long Island City section of Queens. A complex automated system was creating confusion on the floor of the new warehouse, resulting in canceled orders, missing items and long waits.

At the height of the crisis, FreshDirect’s chief executive, Jason Ackerman, stepped down and was replaced by David McInerney, who had helped run the company since the early 2000s. Over the next months, FreshDirect made logistical fixes that gradually eliminated the distribution problems. But plenty of damage had been done.

“We had so much trust, we could’ve built a bank of trust,” Mr. McInerney said in a recent interview. “Over time, that trust was eroded.”