The topup / eddy combo makes the assumption that the third axis corresponds to slices, particularly now with eddy's slice-to-volume motion correction. Therefore phase encoding can’t possibly occur along that axis.
What needs to be done is to permute the image axes so that the direction in which phase encoding was applied appears as one of the first two axes, perform the distortion correction, and then permute the axes back to their original order. This can be done using the -axes option in mrconvert.
I did make an attempt at doing so seamlessly within dwipreproc, but IIRC I got too frustrated because that script is a nightmare. So you’re stuck doing it on your own
Switch second and third axes, so that phase encoding occurs along the second axis: mrconvert DWI.mif -axes 0,2,1,3 DWI_permuted.mif
Run dwifslpreproc: dwifslpreproc DWI_permuted.mif DWI_permuted_preproc.mif ...
Switch second and thrid axes back: mrconvert DWI_permuted_preproc.mif -axes 0,2,1,3 DWI_preproc.mif
``mrconvert DWI.mif -axes 0,2,1,3 DWI_permuted.mif`
However you will not want to apply this blindly, there’s quite a few things that could go wrong (hence why the prospect of modifying dwifslpreproc to do this internally is such a challenge). See for example documentation pages here and here.