Midnight was a memory and, in less than two hours, a groggy House of Representatives had disgorged bills on earthquake hazards, job training, arms control, export trading companies, contract disputes, protection of crime victims and National Christmas Seal Month.

Then came a decision to take up the 19th-century land claims of a Connecticut Indian tribe.

That was too much for Rep. Bill Frenzel (R-Minn.). "We don't have any order here," he shouted, gestur-ing angrily in the direction of the Democratic majority. "We don't know what's going on here. Are we cleaning out the broom closet here?"

Two years of pent-up legislation spilled out of the 97th Congress in a cranky, chaotic 16-hour marathon that ended at 2:33 a.m. yesterday. In the last frenzy of lawmaking before recessing for the election campaign, members of Congress wanted to make sure they had something to take home to the voters.

Rep. Frank R. Wolf (R-Va.) got his $9 million for Wolf Trap Farm Park in a bill that cleared the Senate at 2:07 a.m. Rep. Henry A. Waxman (D-Calif.) had to rush across the Capitol in late evening to rescue his "orphan drug act," held up by several senators who did not understand what was in the bill, a measure to promote research on rare diseases.

In the last day's roller-coaster ride, the Senate passed about 150 bills, and the House about 50, including a multibillion-dollar stopgap funding bill for federal agencies. The president signed it yesterday. Many of the bills whizzed through on voice votes in a matter of seconds, with barely a mumbled mention of the title.

The confusion, common on the day before a recess, is a problem for Washington lobbyists. Frank Holeman, a tire industry representative, called the Senate press gallery yesterday in a tizzy, saying, "I'm desperate to find out what happened to the national highway traffic safety bill. Some people say it passed, some people say it didn't."

The bill had zipped through the Senate in about 15 seconds around 9 p.m.

In the late-night legislating, members became peevish. Rep. John F. Seiberling (D-Ohio) proposed a bill on surplus timber. "I object," Rep. Thomas S. Hartnett (R-S.C.) said. Seiberling sat down.

Moments later, Seiberling again proposed the bill. Hartnett again objected. The scenario was repeated minutes later.

Members groaned and shook their heads as House proceedings ground to a halt. But neither Seiberling nor Hartnett crossed the aisle to discuss their differences.

Finally, Democratic Whip Thomas S. Foley (Wash.) walked over to the Republicans and discovered that Hartnett merely wanted Seiberling to bring up the Wolf Trap bill first, as a favor to his Virginia colleagues. Seiberling, puzzled, did so.

Among the bills passed at a dizzying rate were measures to:

* Make it easier for Asian-born children of U.S. servicemen to enter the United States.

* Increase the federal payment to the District of Columbia.

* Protect barrier islands along the Atlantic and Gulf coasts.

* Create a clearinghouse, using the FBI's computer system, for information on missing children.

* Authorize Nuclear Regulatory Commission programs and allow nuclear plants in some instances to generate electricity before safety hearings are completed.

* Give 13 weeks of federal employment benefits to jobless former servicemen.

* Authorize the Environmental Protection Agency's research operation through September, 1984.

Congress would have recessed earlier, but no one told the House that the Senate was deliberately holding the adjournment resolution hostage until the House passed the Defense Production Act, a bill dealing with contracting procedures.

Meanwhile, both chambers took several recesses, reporters in the galleries watched "Casablanca" and "Dr. Strangelove" on early-morning television and Capitol guards dozed in empty hallways.

By the time the mixup was solved about 2 a.m., most members had gone home to bed. But the defense bill passed on voice votes. Of 435 House members, only a sleepy-eyed Foley and freshman Republican Joe Skeen of New Mexico could be seen on the floor.