PR review comment: This return should be at the bottom of the function so a promise is always returned, even if doc is null.