THE last time Australia was in recession, Mikhail Gorbachev led the Soviet Union and Donald Trump had filed for Chapter 11 only once. Barring unforeseen catastrophe, late next year Australia will pass the Netherlands’ modern record of 26 years of consecutive growth—despite the slowdown of its biggest trading partner, China. Unlike most of the rich world, it sailed through the global financial crisis, and unlike most commodity exporters, it has weathered the raw-materials price slump. Its GDP growth rate of 3.1% dwarfs that of America and the euro zone.

Australia is often called “the lucky country”, and luck, particularly in geology and geography, has played a part in its success. But it has deftly played both sides of the China boom: the surging demand for raw-material imports while that lasted; more recently, the desire of the Chinese middle-class to eat well, travel and educate their children in English. Yet every silver lining has a cloud. Not only does Australia have one of the most expensive housing markets in the world, it remains overexposed to the fortunes of China.

The story of Australia’s success starts with what its government did not do: spend beyond its means. Tight budgets in the late 1990s and early 2000s, combined with improving terms of trade, meant that when the financial crisis hit, the government was running budget surpluses (though the country as a whole has a long-running current-account deficit). It could thus afford stimulus packages in late 2008 and early 2009 worth more than A$56.6 billion ($42.8 billion). Only China provided greater stimulus as a share of GDP.

Australia was then in the middle of the biggest mining boom in its history, stemming from increased demand in China. In the decade to 2012, the value of its mined exports tripled; mining investment rose from 2% of GDP to 8%. From January 2003 to February 2011 the price of iron ore, which these days comprises 17% of Australia’s exports by value, rose from $13.8 to $187.2 a tonne. Australian thermal coal, which accounts for 12% of its exports, rose from $26.7 to $141.9 (down from a peak in 2008 of $192.9).

The Reserve Bank of Australia (RBA) estimates that, during that period, mining raised real disposable household income by 13% and wages by 6%, boosting domestic purchasing power. Saul Eslake, an independent economist, argues that “except for the Chinese people, no country derived more benefit from the growth and industrialisation of China” than Australia. The value of the Australian dollar also rose, which dented non-mining exports. But since demand from Asia kept prices high for Australia’s agricultural commodities (such as beef and wheat), and because it exports relatively few manufactured goods, the damage was contained.

As China rebalanced and commodity prices tumbled, other exporters such as Russia, South Africa and Brazil fell into recession. In Australia, although business investment has fallen sharply, GDP growth remains near its 25-year average of 3% (and as a side benefit, the commodity-price fall quelled rising inflation).

For that, thank two factors. First, the rise in mining investment during the fat years led to increased production. Commodity exports have continued to grow (albeit modestly and less profitably). Though prices of iron ore and coal are well below the past decade’s peaks, they remain above pre-boom levels.

More important, Australia let the dollar depreciate, which made its exports more appealing. Today Australia benefits from a growing number of Chinese consumers, who buy Australian food products that are widely seen as safer than their home-grown equivalents.

Middle-class Asian students have been flocking for English-language education to Australian universities, which are closer and cheaper than their American and British counterparts. Between June 2015 and June 2016 the number of international students enrolled in Australian colleges and universities rose by 11%, and the number of international visitors rose by 13.7%. Today education and tourism together account for 14% of Australia’s export value. Graduates are eligible to work for up to four years, and some stay longer, giving Australia a relatively young, well-educated, multicultural workforce.

Those workers will need places to live, which has helped increase house construction. According to Paul Bloxham, the chief Australia and New Zealand economist at HSBC, Australian builders completed almost 200,000 new dwellings last year, and will probably do the same this year and next. Construction has absorbed some of the employment losses as mining investment has waned (building a mine requires more people than running one).

Yet that has failed to stop an alarming rise in house prices, particularly on Australia’s east coast. In 2015 the median house price in Sydney was 12.2 times the median income, up from 9.8 in 2014. Melbourne’s multiple rose from 8.7 to 9.7 in that period. Some argue that house prices have peaked, and that as residential construction continues prices will moderate (except perhaps in central Sydney). But if prices collapse, that could not just harm Australia’s otherwise healthy banks, but also dampen domestic consumption for years.

Some argue that government debt, which has hit a record 36.8% of GDP, up from a low of 9.7% in 2007, is another worry, because it provides less policy room to deal with the next crisis. It remains lower than in most developed countries. But given the risks of a housing bust or deeper slowdown in China, such worries reflect a healthy lack of complacency. After all, one day the luck will run out.