TypeError: Cannot assign to read only property 'response' of object '[object Object]'
eperitus opened this issue ยท 41 comments
Describe the bug
During a recursive ordered broken link check, blc starts checking and successfully finding broken links, then part of the way through, it hangs, and eventually dumps out a TypeError:
-
/usr/local/lib/node_modules/broken-link-checker/node_modules/bhttp/lib/bhttp.js:159
err.response = response;
^
TypeError: Cannot assign to read only property 'response' of object '[object Object]'
at addErrorData (/usr/local/lib/node_modules/broken-link-checker/node_modules/bhttp/lib/bhttp.js:159:16)
at ClientRequest.<anonymous> (/usr/local/lib/node_modules/broken-link-checker/node_modules/bhttp/lib/bhttp.js:567:25)
at ClientRequest.emit (events.js:316:20)
at Socket.socketErrorListener (_http_client.js:432:9)
at Socket.emit (events.js:316:20)
at emitErrorNT (internal/streams/destroy.js:84:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
To Reproduce
npm install -g broken-link-checker
blc https://example.com -ro
Expected behavior
A completed broken link scan.
Environment:
- OS and version: macOS Catalina 10.15.3
- Node.js version: v13.10.1
- broken-link-checker version: 0.7.8
Possible (terrible) workaround:
Manually go to the last page checked prior to the error, and test each link on that page in your browser. Then remove any links from the page that timeout, for example, links that go to domains that no longer exist.
I got this error as well!
so, i have the same situation
I have the same problem
I also have this error
I debugged this a little bit and on my end it looks like it breaks once it tries to check link which is behind a VPN. In this case it doesn't receive any response (I believe) and fails in a not graceful way.
My workaround is to exclude the hostname in excludedKeywords
option.
It's not a vpn issue for me. One example of where it crashes is when it tries analyzing the following url "blc https://www.ucc.edu/admissions/federal-aid-programs/ -ro"
got the same issue
Same here. It looks like it's all links behind our proxy only urls going through our http(s)_proxy.
We have over 60.000 links to go trough it's not really possible to exclude a certain percentage of them.
I guess it could be handled in a more graceful way, e.x. flag the link as broken with a timeout
reason.
I guess it could be handled in a more graceful way, e.x. flag the link as broken with a
timeout
reason.
I'm not really sure if the link is broken. When checking the links where this occurs manually, they do seem to work (even with a curl from the same server). I do agree that just printing an error and exiting isn't the right way of doing this.
I have the same problem, but only when -r
option is used. What helped me is option like --requests=2
. I'm running checker version 0.7.8 on ubuntu and accessing checked site over VPN.
im having the same problem and none of these answers are helping me
In the first post, I added a really bad workaround, that at least worked for me:
Manually go to the last page checked prior to the error, and test each link on that page in your browser. Then remove any links from the page that timeout, for example, links that go to domains that no longer exist. Then rescan & repeat.
Of course, this won't be feasible for links that do work but are behind a proxy or accessible via a VPN, etc. But perhaps it will help somebody.
I'm having the same problem, but it seems that this originates actually from a problem with the timeout handling of bhttp.
Both adapting the bhttp code or using an older version of bhttp with broken-link-checker (I've only tried it with 1.1.0), fixes the problem for me.
I've got the same behavior here.
I've tried kmanuel's suggestion and it worked.
Guys, I just noticed that the new version of blc does not uses the bhttp module anymore, maybe it's time to use the new blc version.
@kmanuel can you please suggest how to use bhttp with blc? Iโm facing same issue. If you can share an example that would be very helpful
@thiagosanches Which new version? Latest one is 0.7.8
and I still see issue with this version.
Hi @gauravgandhi1315 ,
Actually, master
branch it's not using the bhttp module anymore. If your look for it on package.json there is no reference:
Not sure if master
branch attends your needs. I tried to use but it changed a litte bit the application look n' feel.
@thiagosanches how did you make it work on your machine? Can you share your fix?
@thiagosanches Can you please share how did you see bhttp with blc version 0.7.8? You mentioned in one of your comment that problem solved for you. #184 (comment)
I've promised myself to finish v0.8 this fall. It's summer, so I'm doing other things.
Try:
npm install github:stevenvachon/broken-link-checker && cd node_modules/broken-link-checker && npm run build && ./bin/blc
The API is different for v0.8
@stevenvachon I am still using 0.7.8. So this error will be there for blc 0.7.8? There is no fix for it?
So much has changed from 0.7.8 and bhttp was a problem for a long time. I'm not sure what is causing your issue.
@stevenvachon I get this error only within vpn network. Without vpn, it works fine.
bhttp doesn't support proxies.
@stevenvachon Ok, so blc will not work within vpn network. Is there any work around to fix this issue?
@stevenvachon This library works very well except this issue
It's been a while, but I think v0.8 (master branch) supports proxies. I remember not figuring out how to automate testing them, though.
Hey @gauravgandhi15, sorry for the delay.
The mentioned workaround was to change the bhttp module version. You can try to update on your own package.json and force it to use the 1.1.0 version of that module.
@thiagosanches I am not using bhttp. Just using blc 0.7.8
@thiagosanches Can you give an example on how to use bhttp with blc?
@gauravgandhi15,
That blc version uses the bhttp behind the scenes and its definition is under the package.json
file from the blc repo.
So, for example, on my side I've changed it to use the 1.1.0 version of the bhttp module:
@thiagosanches after installing blc, it did not install bhttp for me. I tried adding in my package.json. Still seeing same error
This seems to fix the problem.
https://git.cryto.net/joepie91/node-bhttp/pulls/5
Now bhttp properly throws the timeout error and blc lists link as broken and does not stop there
ConnectionTimeoutError: The connection timed out.
@jukkapirinen this solved my issue, thanks!
@stevenvachon Any updates on newer version? When are you planning to release it?
Yep, this was caused by a bug in bhttp. I hadn't gotten around to reviewing the PR that fixes it until today. Sorry!
I just released a new version of bhttp, 1.2.8
, which includes the fix. It's a patch release, so updating your dependency tree should pull it in automatically, without any changes on @stevenvachon's part being needed.
(That having been said, it seems that the upcoming releases uses got
instead of bhttp
anyway.)