Timeout for Rest Api

Hi,
When running this code sometimes it will be stuck forever and my thread is stopped.

const { admin, session } = await authenticate.admin(request);

const order = new admin.rest.resources.Order({ session });

order.id = 450789469;
order.customer = null;
await order.save({ update: true });

Is there a way to set timeout so that I can retry it after a cooldown. Currently before this request I am already setting a 2 second delay before this is called to avoid rate limits, but the request is not returning any data and the thread is stuck.

I would recommend updating to GraphQL as REST API is deprecated.
It’s likely an issue with trying to null the customer, as that seems a strange pattern to do once an orders placed.