Bubble bursting and subsequent collapse of the open cavity at free surfaces of contaminated liquids can generate aerosol droplets, facilitating pathogen transport. After film rupture, capillary waves focus at the cavity base, potentially generating fast Worthington jets that are responsible for ejecting the droplets away from the source. While extensively studied for Newtonian fluids, the influence of non-Newtonian rheology on this process remains poorly understood. Here, we employ direct numerical simulations to investigate the bubble cavity collapse in viscoelastic media, such as polymeric liquids. We find that the jet and drop formations are dictated by two dimensionless parameters: the elastocapillary number
$Ec$ (the ratio of the elastic modulus and the Laplace pressure) and the Deborah number
$De$ (the ratio of the relaxation time and the inertio-capillary time scale). We show that, for low values of
$Ec$ and
$De$, the viscoelastic liquid adopts a Newtonian-like behaviour, where the dynamics is governed by the solvent Ohnesorge number
$Oh_s$ (the ratio of visco-capillary and inertio-capillary time scales). In contrast, for large values
$Ec$ and
$De$, the enhanced elastic stresses completely suppress the formation of the jet. For some cases with intermediate values of
$Ec$ and
$De$, smaller droplets are produced compared with Newtonian fluids, potentially enhancing aerosol dispersal. By mapping the phase space spanned by
$Ec$,
$De$ and
$Oh_s$, we reveal three distinct flow regimes: (i) jets forming droplets, (ii) jets without droplet formation and (iii) absence of jet formation. Our results elucidate the mechanisms underlying aerosol suppression versus fine spray formation in polymeric liquids, with implications for pathogen transmission and industrial processes involving viscoelastic fluids.