Skip to content

Commit 9c58b35

Browse files
committed
Fix crash when no entityService is defined
Resolves feathersjs-ecosystem#526
1 parent 402a00b commit 9c58b35

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/socket/handler.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ function handleSocketCallback (promise, callback) {
2121
export default function setupSocketHandler (app, options, { feathersParams, provider, emit, disconnect }) {
2222
const authSettings = app.get('authentication') || app.get('auth');
2323
const service = app.service(authSettings.path);
24-
const entityService = app.service(authSettings.service);
24+
let entityService;
25+
if (authSettings.service) {
26+
entityService = app.service(authSettings.service);
27+
}
2528
let isUpdateEntitySetup = false;
2629

2730
return function (socket) {
@@ -152,7 +155,7 @@ export default function setupSocketHandler (app, options, { feathersParams, prov
152155
socket.on('logout', logout);
153156

154157
// Only bind the handlers on receiving the first socket connection.
155-
if (!isUpdateEntitySetup) {
158+
if (!isUpdateEntitySetup && entityService) {
156159
isUpdateEntitySetup = true;
157160
entityService.on('updated', updateEntity);
158161
entityService.on('patched', updateEntity);

0 commit comments

Comments
 (0)