This is not how numbers are usually generated, and if this is happening it must be a bug. Invoice numbers are generated when the invoice is saved as a draft. If numbers are being created before being saved as a draft, then a git hub issue should be created, because this is a bug. A draft invoice is not the same as a pro-forma invoice though. At least in my company, we use Sales Orders for Pro-Forma invoices.A draft invoice is simply a draft invoice, i.e. it's not complete.
Draft invoices must be numbered, else it would ruin the organization. If you have an invoice that is still a draft, a mistake, and you don't want any gaps, then you should submit then cancel the invoice. It won't affect any accounts, and will still be a permanent record.
You should change permissions so that nobody can delete invoices.