This is a pilot randomised controlled trial comparing open versus thoracoscopic surgery for repair of oesophageal atresia with tracheo-oesophageal fistula or congenital diaphragmatic hernia in neonates. Thoracoscopic surgery involves insufflation of carbon dioxide into the thoracic cavity and may therefore cause hypercapnia and acidosis.