Skip to content

Conversation

@cristiklein
Copy link
Contributor

In certain odd cases, like a website returning a 302 and/or closing the connection after a HEAD (I'm not 100% sure), linkCheck will call our callback twice. async is not amused and will throw:

Error: Callback was already called

A campaign of ad-hoc console.log()s suggest this is a bug in needle, a library used by link-check.

Fixes #222 and #473

In certain odd cases, like a website returning a 302 and/or closing the
connection after a HEAD (I'm not 100% sure), linkCheck will call our
callback twice. `async` is not amused and will throw:

> Error: Callback was already called

A campaign of ad-hoc `console.log()`s suggest this is a bug in needle, a
library used by link-check.

Fixes tcort#222 and tcort#473
@BaseMax
Copy link
Collaborator

BaseMax commented Nov 17, 2025

Many thanks. Lets to fully test it to make sure it's ready to be merged.

@cristiklein
Copy link
Contributor Author

@BaseMax I finally managed to precisely trigger the bug in needle. Seems like it only occurs when a server response to HEAD with a 302 and a body, which is against the HTTP spec.

I added a test case of that.

I was hoping I could also squeeze in an .editorconfig. 😄

PTAL!

@BaseMax
Copy link
Collaborator

BaseMax commented Nov 18, 2025

Many thanks again for your tests as well.

Copy link
Collaborator

@BaseMax BaseMax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLGTM

@BaseMax BaseMax merged commit e6f295b into tcort:master Nov 18, 2025
0 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error "Callback was already called." when setting httpHeaders in mlc_config.json

2 participants