  It is believed that the relativistic jets of gamma-ray bursts (GRBs) should
initially propagate through a heavy envelope of the massive progenitor stars or
through a merger ejecta formed from the compact binary mergers. The interaction
of a jet with a stellar envelope or a merger ejecta can lead to the
deceleration of the head material of the jet and simultaneously the formation
of a hot cocoon. However, this jet-envelope/ejecta interaction is actually
undetectable with electromagnetic radiation and can only be inferred indirectly
by the structure of the breakout jet. Therefore, as a solution to this
phenomenon, we suggest that the jet-envelope/ejecta interaction can produce a
gravitational-wave (GW) memory of an amplitude of $h\sim10^{-26}-10^{-23}$,
which could be detected with some future GW detectors sensitive in the
frequency range from sub-Hertz to several tens of Hertz. This provides a
potential direct way to probe the jet propagation and then the interior of the
GRB progenitors. Moreover, this method is in principle available even if the
jet is finally chocked in the stellar envelope or the merger ejecta.
