mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 23:33:12 +09:00
Log synchronous throws from handleUdp handlers
The listener runs from the socket callback, so a non-async handler that threw before returning a promise reached the unhandled error handler and took down the host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fb53845f2a
commit
25c3c9991e
2 files changed
+22
-3
No files matched your search
@@ -471,6 +471,20 @@ describe("host/server", function() {
|
||||
assert.equal(lines.length, 1);
|
||||
assert(lines[0].startsWith("Error handling udp event:\nError: boom"), lines[0]);
|
||||
});
|
||||
it("should log errors thrown synchronously by handleUdp handlers", async function() {
|
||||
await server._startUdp();
|
||||
server.handleUdp("sync", () => { throw new Error("sync boom"); });
|
||||
const { lines, restore } = captureLogger("error");
|
||||
try {
|
||||
sendFromGame("sync?data");
|
||||
while (lines.length < 1) {
|
||||
await wait(1);
|
||||
}
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
assert(lines[0].startsWith("Error handling udp event:\nError: sync boom"), lines[0]);
|
||||
});
|
||||
it("should forward socket errors", async function() {
|
||||
await server._startUdp();
|
||||
let waiter = events.once(server, "error");
|
||||
|
||||
Reference in new issue
Block a user