Skip to content

Commit c5ec215

Browse files
JohnMcLearclaude
andcommitted
Fix hook callback called multiple times in registerRoute
The Etherpad hook system expects cb() to be called exactly once per hook invocation. In registerRoute, cb() was being called inside the /p/*/feed route handler on every HTTP request (up to 5 times per request depending on code path), in addition to the correct call at the end of the hook. This could cause unpredictable behavior in the hook system. Remove all cb() calls from inside route handlers, keeping only the single call after all routes are registered. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent da6761a commit c5ec215

1 file changed

Lines changed: 0 additions & 6 deletions

File tree

index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ exports.registerRoute = (hookName, args, cb) => {
6666
if (!isPublished) { // If it's not already published and it's gone stale
6767
feeds[padId].lastEdited = message.lastEdited; // Add it to the timer object
6868
}
69-
cb();
7069
} else {
7170
if (!feeds[padId].feed) { // If it's not already stored in memory
7271
console.debug('RSS Feed not already in memory so writing memory', feeds);
@@ -75,20 +74,16 @@ exports.registerRoute = (hookName, args, cb) => {
7574
} else {
7675
isPublished = true;
7776
}
78-
cb();
7977
}
8078
if (!isPublished) {
8179
const pad = await padManager.getPad(padId);
8280
text = safe_tags(pad.text()).replace(/\n/g, '<br/>');
83-
} else {
84-
cb();
8581
}
8682

8783
if (isPublished) {
8884
console.debug(`Sending RSS from memory for ${padId}`);
8985
res.contentType('rss');
9086
res.send(feeds[padId].feed);
91-
cb();
9287
} else {
9388
console.debug(`Building RSS for ${padId}`);
9489
res.contentType('rss');
@@ -117,7 +112,6 @@ exports.registerRoute = (hookName, args, cb) => {
117112
args.content += '</rss>';
118113
feeds[padId].feed = args.content;
119114
res.send(args.content); // Send it to the requester
120-
cb(); // Am I even called?
121115
}
122116
});
123117
cb();

0 commit comments

Comments
 (0)