The Senate had legislated through the night, pushing on past the dawn yesterday, and now the threat of a government shutdown hinged on debate over a Pennsylvania chicken farmer's claims against Uncle Sam.

The amendment by Sen. John Heinz (R-Pa.) was not about to shake the republic, but it seemed of a piece with the endless process that had tied the Senate in knots for 21 consecutive hours and 32 minutes.

Along the way, with fiscal 1985 having begun on Monday, and with dozens of federal agencies' power to spend money in jeopardy, the bureaucracy was preparing to go home at midday unless the Senate could break its logjam.

The Heinz amendment, providing $61,867 to farmer Roger Moyer of Lititz, Pa., was just one of scores that senators were attaching to the long-stalled continuing resolution authorizing fiscal 1985 spending.

Not long after Heinz called up his amendment at 8:58 a.m., with the Senate churning through its 21st consecutive hour, Majority Leader Howard H. Baker Jr. (R-Tenn.) threw up his hands for the umpteenth time and declared a recess until afternoon.

These were the closing hours of Baker's 18 years in the Senate, the end of his leadership role, and he wasn't going out in glory. His counterpart, Minority Leader Robert C. Byrd (D-W.Va.), in a farewell tribute to Baker, diplomatically avoided mentioning that Republicans weren't making the trains of legislation run very well.

There was less diplomacy at the other end of the Capitol, however, where House members smugly chafed over the Senate's seeming inability to complete work on the continuing resolution, clear the way for adjournment of the 98th Congress and free them to rush out to their election campaigning.

Rep. Silvio O. Conte (R-Mass.), in a burst of whimsy that came close to bridging proscriptions against direct criticism, took to the House floor and recited some doggerel describing a dream in which the Senate end of the Capitol had crashed in flames. His "Ode to A Hundred Neros" ended thusly:

"What happened next, I do not know. God saved me, I awoke. But one half of the Capitol was left in dust and smoke.

"The symphony composed last night would put Mozart to shame -- but the orchestra's a laughingstock, and gluttony's to blame."

There was laughter for the uncrowned laureate of the "people's chamber," but by midday, with President Reagan having laid blame for the governmental shutdown on the House, the Democrats who were stuck waiting for action in the Republican-controlled Senate were furious.

Majority Leader James C. Wright Jr. (D-Tex.) angrily charged that Reagan had impugned the honor of the House in another "very typical" political gesture. He carefully recited the record since 1981, describing in detail how House-passed spending measures repeatedly have gotten trapped in the Senate.

Rep. Robert S. Walker (R-Pa.) leaped to his feet to challenge Wright's direct references to "the other body," as the Senate customarily is called, and his questioning of its "actions."

The current blockade over the continuing resolution was not a record-breaker, but it ranked right up there among recent marathon sessions. In 1982, for example, the Senate went consecutively for 37 hours and 51 minutes in an effort to wrap up pending business. In 1981, it went 20 hours and 52 minutes; in 1978, on a weekend, it went 34 hours and 16 minutes.

The scene yesterday was much the same as in those previous times of stress. As the Senate went on through its night, senators tacking all manner of random spending goodies to the resolution, papers littered the desks. Staffers slouched wearily on seats at the rear of the chamber. Blanket-covered mounds on cloakroom couches suggested senators working hard at sleep.

The predicament the Senate had worked itself into began to take shape weeks ago. There was stalemate over defense spending, exacerbated when Reagan refused to budge on his proposals. More delays over budget procedures backlogged appropriations bills.

By then, with a clogged calendar and fiscal 1984 nearing its Sept. 30 end, Senate leaders agreed to wrap nine pending appropriations measures into the continuing resolution and ram it through after the House had moved its own version with dispatch.

The Senate took it up early last week, but it quickly began taking on the look of a well-adorned Christmas tree with senatorial add-ons, even as veto threats rumbled from the White House. More than four full days were lost in a conservative filibuster of civil rights legislation that was tacked to it.

Once the rights measure was removed, though, temptation ran amok. Dozens of new home-state favorite projects were added and the Senate, under its rules, was forced to deal with each and every one.

Thus, for example, at 10:15 p.m. Wednesday, Sen. Carl Levin (D-Mich.) could get $12 million added to improve U.S. Route 10 around Pontiac and East Lansing. Sen. Bill Bradley (D-N.J.), at 1:32 a.m. yesterday, got $400,000 to study a 1932-1933 famine in the Soviet Ukraine. At 3:30 a.m., Sen. Bob Packwood (R-Ore.) was fighting in vain against a Florida-led move to exempt planes landing at Miami and Bangor, Maine, airports from noise-control rules.

And then there was the chicken-farmer amendment. Heinz was seeking money for Roger Moyer and another $136,167 for the Keystone Mills of Ephrata, Pa., to pay for the chickens that were gassed after the Department of Agriculture erred during an outbreak of avian influenza last winter.

As justified as the claim might have been, it got lost in the shuffle. As work was completed on the continuing resolution in the afternoon, Heinz was away at a meeting, unable to plead the case. Appropriations Chairman Mark O. Hatfield (R-Ore.) had the amendment tabled and there wasn't a single squawk.