Function waitUntil

  • When you want to run a async process but don't want to block your application to wait for it to finish, you can use the defer function.

    This let you run the async process as a run and forget, the process will run in the background until it's completed and the Worker will not shutdown in the meantime.

    In many cases this can solve the problem of a background Job too, but consider that in case of failure the process will not be retried.

    Parameters

    • promise: Promise<unknown>

      The promise to defer

    Returns void

    defer(analytics.track("event", { user }));