  A new thermonuclear $^{17}$O($n$,$\gamma$)$^{18}$O rate is derived based on a
complete calculation of the direct-capture (DC) and resonant-capture
contributions, for a temperature region up to 2 GK of astrophysical interest.
We have firstly calculated the DC and subthreshold contributions in the energy
region up to 1 MeV, and estimated the associated uncertainties by a Monte-Carlo
approach. It shows that the present rate is remarkably larger than that adopted
in the JINA REACLIB in the temperature region of 0.01 $\sim$ 2 GK, by up to a
factor of $\sim$80. The astrophysical impacts of our rate have been examined in
both $s$-process and $r$-process models. In our main $s$-process model which
simulates flash-driven convective mixing in metal deficient asymptotic giant
branch stars, both $^{18}$O and $^{19}$F abundances in interpulse phases are
enhanced dramatically by factors of $\sim 20$--$40$ due to the new larger
$^{17}$O($n$,$\gamma$)$^{18}$O rate. It shows, however, that this reaction
hardly affects the weak $s$-process in massive stars since the $^{17}$O
abundance never becomes significantly large in the massive stars. For the
$r$-process nucleosynthesis, we have studied impacts of our rate in both the
collapsar and neutron burst models, and found that the effect can be neglected,
although an interesting "loophole" effect is found owing to the enhanced new
rate, which significantly changes the final nuclear abundances if fission
recycling is not involved in the model, however, these significant differences
are almost completely washed out if the fission recycling is considered.
