Have you checked that the bug is not already fixed?
Yes
Summary
markdown-link-check crashes somewhat randomly with Error: Callback was already called.
Affected version
3.13.7, commit b88c7e6
Steps to reproduce the bug
It seems it check the same link twice, calling a callback create by onlyOnce twice, causing a crash
Minimal example below:
For privacy reason, I cannot disclose the exact links, but they return a 200 statusCode.
I was not able to find a public link pairs that triggered the crash.
dir1/index.md
dir2/index.md:
$ docker run -it -v $HOME/dummy_doc/:/tmp:ro $(docker build -q .) --verbose /tmp/
FILE: /tmp/dir1/index.md
ERROR: XXX null LinkCheckResult {
link: 'https://link1.com',
statusCode: 200,
err: null,
status: 'alive'
}
[✓] https://link1.com → Status: 200
1 links checked.
FILE: /tmp/dir2/index.md
ERROR: XXX null LinkCheckResult {
link: 'https://link1.com',
statusCode: 200,
err: null,
status: 'alive'
}
/src/node_modules/async/dist/async.js:325
if (fn === null) throw new Error("Callback was already called.");
^
Error: Callback was already called.
at /src/node_modules/async/dist/async.js:325:36
at /src/node_modules/async/dist/async.js:249:17
at /src/index.js:214:13
at /src/node_modules/link-check/lib/proto/http.js:119:21
at done (/src/node_modules/needle/lib/needle.js:474:14)
at PassThrough.<anonymous> (/src/node_modules/needle/lib/needle.js:734:9)
at PassThrough.emit (node:events:519:35)
at endReadableNT (node:internal/streams/readable:1701:12)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
The error log comes from this line I added:
diff --git a/index.js b/index.js
index 167e9d4..5687ec2 100644
--- a/index.js
+++ b/index.js
@@ -209,6 +209,8 @@ module.exports = function markdownLinkCheck(markdown, opts, callback) {
result.status = 'error'; // custom status for errored links
}
+ console.error("ERROR: XXX %s", err, result);
+
callback(null, result);
});
}, callback);
Note that markdown-link-check believe the dir2/index.md contain a link to link1.com, which is false.
In other runs, markdown-link-check believed dir2/index.md contained the two links
To me it looks like a race condition
The problem only appear for some links
It is probably linked to: #222
Expected behavior
It should not crash and don't mix up links
Actual behavior
Additional context
No response
Can you fix it?
Yes
Have you checked that the bug is not already fixed?
Yes
Summary
markdown-link-check crashes somewhat randomly with
Error: Callback was already called.Affected version
3.13.7, commit b88c7e6
Steps to reproduce the bug
It seems it check the same link twice, calling a callback create by
onlyOncetwice, causing a crashMinimal example below:
For privacy reason, I cannot disclose the exact links, but they return a 200 statusCode.
I was not able to find a public link pairs that triggered the crash.
dir1/index.md
dir2/index.md:
The error log comes from this line I added:
Note that markdown-link-check believe the
dir2/index.mdcontain a link tolink1.com, which is false.In other runs, markdown-link-check believed
dir2/index.mdcontained the two linksTo me it looks like a race condition
The problem only appear for some links
It is probably linked to: #222
Expected behavior
It should not crash and don't mix up links
Actual behavior
Additional context
No response
Can you fix it?
Yes