broken-link-checker: TypeError: Cannot assign to read only property 'response' of object '[object Object]'

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.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 15
  • Comments: 41 (5 by maintainers)

Most upvoted comments

I guess it could be handled in a more graceful way, e.x. flag the link as broken with a timeout reason.

@stevenvachon Any updates on newer version? When are you planning to release it?

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 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

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.)