Hi Christian - many thanks for the pointer.  hof:until works well and without a double http:send-request.

let $pollingResult := hof:until(function($result) {$result?3//status/text()= 'done'},function ($input){[$input?1 + 1,prof:sleep(5000),http:send-request($requestPolling)]}, [1,0,http:send-request($requestPolling)])

On Fri, Aug 13, 2021 at 6:29 PM Christian Grün <christian.gruen@gmail.com> wrote:
> If polling a url n times and breaking if response is 'completed', is the best to approach to use try catch and error() to get around immutability?  I need the full response on complete so I redo the last http get. It is not a biggie requesting twice. Adam

The hof:until function may help you [1]. Don’t hesitate to supply us
with a minimized code snippet.

In general, it’s almost always a good advice not to use try/catch
unless you need to catch real errors.

[1] https://docs.basex.org/wiki/Higher-Order_Functions_Module#hof:until