Closed nickhammond closed 11 months ago
I assume you are opening file directly with go_to
?
@route Yes, to the https://example.com/download/data.xlsx
URL after we've figured out what other parameters that need to be added to it.
I'm not 100% sure if I see the same issue. When updating to ferrum
0.14 (from 0.13) which I'm using indirectly via cuprite
(0.14.3 → 0.15).
On GitHub Actions we now have a test consistently failing, although I'm having a hard time reproducing it locally. It is failing here:
visit download_file_fixture_path(file)
with:
[…]
Ferrum::StatusError:
Request to http://app.localhost:41805//ds/94ty7cwb/download failed (net::ERR_ABORTED)
[…]
EDIT: Interestingly I can reproduce it on my x86 MacBook Pro 🤔
@tisba I'm pretty sure you started to use new Chrome 119 which broke something. Check your logs before on the successful build and after it started to fail for Chrome version.
Good point, I totally forgot about Chrome itself 🤦♂️
Can't access my M1 MacBook Pro right now to check the version where it worked. On my x86 MacBook Pro (using Docker) I can reproduce the issue with:
Chromium 118.0.5993.0
- that's the version I had initially; exact same version I'm getting at GitHub ActionsChromium 119.0.6045.105
- fails alsoDowngrading to Chromium 116.0.5845.180
fixed the issue locally.
I can find references to ERR_ABORTED
in logs for all versions. It's a lot of output, anything in particular you want me to look for, @route?
Maybe there is an issue with Chrome versions, but this feels more related to upgrading ferrum
(0.13 -> 0.14) and/or cuprite
(0.14.3 → 0.15). With the identical Chrome version it works before the update and breaks consistently after.
I doubt that because you can see latest builds of ferrum https://github.com/rubycdp/ferrum/commits/main
Need some more time building a simplified example. At least in our case, the issue is not occuring when staying at ferrum 0.13 and cuprite 0.14.3, both locally on my MacBook Pro (x86) as well as on GitHub Actions 🤷
@nickhammond can you tell me your Chrome version?
@route I'll have to test again to ensure it's still happening since I ended up patching and pointing to my own fork.
Chrome: 118.0.5993.70 Patch: https://github.com/nickhammond/ferrum/commit/b2bc60641382673326d11fd4057727ebf8d44107
Chrome 119 started to send:
{"method":"Page.frameStoppedLoading","params":{"frameId":"69FE7B40C52D828E8A4681686395EAC8"}}
for the main request which was always missing before. In fact Chrome was always returning an error for the main request:
◀ 0.6014469999936409 {"method":"Network.loadingFailed","params":{"requestId":"B6E447A057194D37B4873953C9448868","timestamp":353280.996004,"type":"Document","errorText":"net::ERR_ABORTED","canceled":true}}
◀ 0.6015239999978803 {"id":1011,"result":{"frameId":"69FE7B40C52D828E8A4681686395EAC8","loaderId":"B6E447A057194D37B4873953C9448868","errorText":"net::ERR_ABORTED"}}
but was missing to send Page.frameStoppedLoading
this is why it broke now.
I believe it works like this because it downloads file in the subprocess, and it doesn't make sense for it to continue main request since it's the same file, so it always cancels main request and starts subprocess to download file. When download is finished the browser gets notification or in case of headless instance Page.downloadProgress
is returned with status completed
.
page.go_to("/filename")
is always failing when we download file because errorText's returned and by protocol it means: User friendly error message, present if and only if navigation has failed.
So we must raise an error. I understand that it's frustrating, I think in this case we can consider net::ERR_ABORTED
as due to user action or download and not raise an error./cc @tisba @nickhammond
@route Nice digging, appreciate the context! Yah, when I was looking through that network log I wasn't entirely sure what looked normal and what didn't.
@route Nice work! I'll update our app to point to this version.
Started seeing a weird network/download issue with Ferrum and ended up pinpointing it to the
Network.loadingFailed
event but weirdly I'm not seeing anything get aborted in the network activity tab.I'm seeing this
Network.loadingFailed
event which mentions that it was cancelled, could it be cancelled because a download was triggered?It looks like the go_to method initially was listening to network level errors like DNS and connectivity. https://github.com/rubycdp/ferrum/commit/9217224d7079434cfdb18b54eadaac5df97f4da7#diff-2f9537c613f48bed5ff6ca273e2dac28886a32fe78dcd2dc7c7c798c891434d3R78 but was changed to just listen to any error coming back.
Since the browser most recently saw a
Network.loadingFailed
event but not a subsequentNetwork.loadingFinished
or any other network event, just page and browser events, theresponse["errorText"]
is still set even though the download has already started and is in progress. https://github.com/rubycdp/ferrum/blob/main/lib/ferrum/network.rb#L414This causes the aborted error to be raised even though the download continues to go through and complete.