Who was making the loans to the Soviets specifically? For all the hard rhetoric of the 80s, it's quite interesting that the West was willing to prop up a (Communist!!!) entity for a fee.
"In retrospect, it is possible to see that bank confidence had begun to
erode as early as the latter part of 1988. In the fall of that year, new
patterns of bank lending to the Soviet Union appeared. Previously, it
was typical for banks from many nations to participate in syndications for loans to the Soviet Union. Beginning in October 1988,
though, a number of very large loans were negotiated with purely
national syndications-that is, all participating banks were from a
single Western country. Western governments played important
roles in arranging these syndications, and usually the loans were to
finance exports from the lending country. At the time, a number of
Western governments were intent on providing material support for
the processes of economic and political reform perceived to be under
way in the Soviet Union. By intervening with banks on behalf of the
Soviet Union-either directly through loan guarantees or through
less formal encouragement of bank lending-these governments probably helped the Soviet Union to achieve better terms from the banks
than it could have gotten on its own. By mid-1990, bank confidence
had declined sufficiently that banks would lend to the Soviet Union
only with explicit guarantees from Western governments."
To answer your question though, I believe it was primarily Western European countries providing or guaranteeing the funds by 1989.
At the time, Gorbachev was seen as a reformer, and the West was willing to grant him some rope in the form of hard currency loans, but that would have evaporated if he had pulled a Prague in Warsaw or East Berlin.