Thank you for the advice, I managed to solve it with a combination of:
-DNDEBUG
-DCORE_DEBUG_LEVEL=0
in the .ini file. I also found that if I switched to using:
gpio_install_isr_service(ESP_INTR_FLAG_EDGE);
gpio_set_intr_type((gpio_num_t)pinNumber, GPIO_INTR_POSEDGE);
gpio_isr_handler_add((gpio_num_t)pinNumber, isr, NULL);
it made the error disappear but I’ll use the .ini file solution as this is preferable.
Many thanks,
Owen