mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +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
@@ -771,9 +771,14 @@ export class FactorioServer extends events.EventEmitter<FactorioServerEvents> {
|
||||
}
|
||||
|
||||
handleUdp(channel: string, handler: (data: Buffer) => Promise<void>) {
|
||||
this.on(`udp-${channel}`, (data) => handler(data).catch((err: Error) => {
|
||||
this._logger.error(`Error handling udp event:\n${err.stack ?? err.message}`);
|
||||
}));
|
||||
// Runs from the socket callback, so synchronous throws must be caught here too
|
||||
this.on(`udp-${channel}`, async (data) => {
|
||||
try {
|
||||
await handler(data);
|
||||
} catch (err: any) {
|
||||
this._logger.error(`Error handling udp event:\n${err.stack ?? err.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async _handleIpc(line: Buffer) {
|
||||
|
||||
Reference in new issue
Block a user