In Jackson's Classical Electrodynamics, Section 5.4 (Vector Potential), the author seems to assume that because $\nabla\cdot\mathbf{J} = 0$, the following holds for the current density (where the integral is done over all space):
$$\nabla\cdot\iiint\frac{\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\mathrm{d}V' = 0$$
However, in general we know that in a closed volume $V$, we have: $$\nabla\cdot\iiint\limits_V\frac{\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\mathrm{d}V' = \iiint\limits_V\nabla\cdot\frac{\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\mathrm{d}V' = \iiint\limits_V\mathbf{J}(\mathbf{x}')\cdot\nabla\left(\frac{1}{\left|\mathbf{x}-\mathbf{x'}\right|}\right)\mathrm{d}V'$$ $$ = -\iiint\limits_V\mathbf{J}(\mathbf{x}')\cdot\nabla'\left(\frac{1}{\left|\mathbf{x}-\mathbf{x'}\right|}\right)\mathrm{d}V' = -\iiint\limits_V\nabla'\cdot\frac{\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\mathrm{d}V' + \iiint\limits_V\frac{\nabla'\cdot\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\mathrm{d}V'$$
Now in the magnetostatic case, we know from the continuity equation $\nabla\cdot\mathbf{J}+\frac{\partial\rho}{\partial t} = 0$ that in fact, $\nabla\cdot\mathbf{J} = 0$ over all space (because there are no local charge density fluctuations), and so the second term goes away and we are left with:
$$\nabla\cdot\iiint\limits_V\frac{\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\mathrm{d}V' = -\iiint\limits_V\nabla'\cdot\frac{\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\mathrm{d}V' = -\mathop{\LARGE\unicode{x222f}}\limits_{\partial V}\frac{\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\cdot\mathrm{d}\mathbf{S}'$$
Now taking a limit as the volume becomes the entire space, we see that the surface integral is taken in regions increasingly far away from $\mathbf{x}$. If we make certain assumptions on the asymptotics of $\mathbf{J}$, such as $|\mathbf{J}(\mathbf{x}')| = o\left(\frac{1}{\left|\mathbf{x}-\mathbf{x}'\right|}\right)$, then we can bound the surface integral and show that it tends to zero.
Physically speaking, one could argue that this is enough because realistic systems will always have currents bound in a finite volume anyway. But sometimes we consider idealized scenarios such as infinite straight lines with a uniform current $I$. These cases might cause trouble. If you only have a single (or finitely many) such wires, I think you can still show the integral goes to zero because of the inverse dependence to the distance in the integrand (I am not certain). But even then, one could reasonably imagine idealized situations comprising infinitely many such wires that could make the surface integral not converge to zero.
Another difficulty is that the convergence ought to hold for any surface that encloses all of space eventually. If we restrict to spheres of radius $|\mathbf{x}-\mathbf{x}'| = R$ centered around $\mathbf{x}$, then the convergence is trivial because we get $$-\mathop{\LARGE\unicode{x222f}}\limits_{\partial V}\frac{\mathbf{J}(\mathbf{x}')}{\left|\mathbf{x}-\mathbf{x'}\right|}\cdot\mathrm{d}\mathbf{S}' = -\frac{1}{R}\mathop{\LARGE\unicode{x222f}}\limits_{\partial V}\mathbf{J}(\mathbf{x}')\cdot\mathrm{d}\mathbf{S}' = 0$$ (by the divergence theorem and continuity equation). But if your surfaces are non-spherical, this trick does not really work anymore. But maybe there is a way to avoid this issue.
I am interested in knowing the most general assumptions that can be made on $\mathbf{J}$ to satisfy the convergence, and also in knowing about situations that might be considered where this assumption is wrong.