You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that when I do await response.finished() // wait for response to finish (inside the callback for page.on('response", onResponse)) that if the browser is closed, then this line throws an error "Target page, context or browser has been closed".
It throws even after the callback is unregistered with page.off("response", onResponse), but that makes sense since any prior response is still in flight.
So is there a way though to cancel any inflight pending response.finished() promises so that they don't throw when the page is closed?
I actually mainly want to cancel them because I may open multiple pages over time, and I don't want a request from an old page to be waiting forever if that response never finished.
So if I know that I am "done" with a page even though I am keeping the page tab open, it would be nice if I can manually cancel any still in flight pending response.finished() responses.
There isn't much we can offer at this point. You can catch that finished() call or you can add it to a list of promises that you await / mute in the end of your test manually. We are thinking about joining the event handlers in the end of the test though, so I'll leave this open.
Page(s)
https://playwright.dev/docs/api/class-response#response-finished
Description
I noticed that when I do
await response.finished() // wait for response to finish
(inside the callback forpage.on('response", onResponse)
) that if the browser is closed, then this line throws an error "Target page, context or browser has been closed".It throws even after the callback is unregistered with
page.off("response", onResponse)
, but that makes sense since any prior response is still in flight.So is there a way though to cancel any inflight pending response.finished() promises so that they don't throw when the page is closed?
The text was updated successfully, but these errors were encountered: