Fix attach stream closing issues Upstream-commit: 23b48fbe146b6412390e18eb9ac8173ef43e73df Component: engine