There is no legal precedent for the Article 50 deadline. No nation has triggered it before. Nor has any nation left the EU before.
Therefore, the deadline is more flexible than many believe. The UK could negotiate an extension with the EU. If the EU believes that a second referendum may be on the cards it should be amenable to the idea, especially if the option to remain in the EU is on the ballot, given it wants the UK to remain in the union.