There is no good way to know whether the caller is handling a promise rejection. There are hacks that work in some circumstances, but I would not suggest going there.
ALL promises require that the caller handle any possible rejections - it is not optional. That is the law with promises. That's part of the contract for using your API. That's not your API's responsibility itself to try to make up for a client writing bad code and promises are not designed to make that feasible.
So, it's not an option for you to change your function's behavior based on whether a promise rejection is or isn't being handled.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…