fix: avoid crashing on handler import/execution
Can't do much for events, but at least here we can ignore the errors.
This commit is contained in:
parent
b7f2073380
commit
39f7e4e92e
1 changed files with 7 additions and 2 deletions
|
|
@ -36,8 +36,13 @@ function on_connection(socket) {
|
|||
let file = `../../${app}/realtime/handlers.js`;
|
||||
let abs_path = path.resolve(__dirname, file);
|
||||
if (fs.existsSync(abs_path)) {
|
||||
let handler_factory = require(file);
|
||||
handler_factory(socket);
|
||||
try {
|
||||
let handler_factory = require(file);
|
||||
handler_factory(socket);
|
||||
} catch (err) {
|
||||
console.warn(`failed to load event handlers from ${abs_path}`);
|
||||
console.warn(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue