Consider the following definite real integral: $$I = \int_{0}^\infty dx \frac{e^{-ix} - e^{ix}}{x}$$
Using the $\text{Si}(x)$ function, I can solve it easily, $$I = -2i \int_{0}^\infty dx \frac{e^{-ix} - e^{ix}}{-2ix} = -2i \int_{0}^\infty dx \frac{\sin{x}}{x} = -2i \lim_{x \to \infty} \text{Si}(x) = -2i \left(\frac{\pi}{2}\right) = - i \pi,$$ simply because I happen to know that $\mathrm{Si}(x)$ asymptotically approaches $\pi/2$.
However, if I try to calculate it using the residue theorem, I get the wrong answer, off by a factor of $2$ and I'm not sure if I understand why. Here's the procedure: $$I= \int_{0}^\infty dx \frac{e^{-ix}}{x} - \int_{0}^\infty dx \frac{ e^{ix}}{x} = \color{red}{-\int_{-\infty}^0 dx \frac{e^{ix}}{x}} - \int_{0}^\infty dx \frac{ e^{ix}}{x} = -\int_{-\infty}^\infty dx \frac{e^{ix}}{x} $$ Then I define $$I_\epsilon := -\int_{-\infty}^\infty dx \frac{e^{ix}}{x-i\varepsilon}$$ for $\varepsilon > 0$ so that$$I=\lim_{\varepsilon \to 0^+} I_\varepsilon.$$ Then I complexify the integration variable and integrate over a D-shaped contour over the upper half of the complex plane. I choose that contour because $$\lim_{x \to +i\infty} \frac{e^{ix}}{x-i\varepsilon} = 0$$ and it contains the simple pole at $x_0 = i \varepsilon$. Using the residue theorem with the contour enclosing $x_0$ $$I_\varepsilon = -2 \pi i \, \text{Res}_{x_0} \left( \frac{e^{ix}}{x-i\varepsilon}\right) = -2 \pi i \left( \frac{e^{ix}}{1} \right)\Bigg\rvert_{x=x_0=i\varepsilon}=-2 \pi i \, e^{-\varepsilon}.$$ Therefore, $$I=\lim_{\varepsilon \to 0^+} \left( -2 \pi i \, e^{-\varepsilon} \right) = -2\pi i.$$
However, that is obviously wrong. Where exactly is the mistake?