Skip to content

Crash | TypeError: service._emit is not a function #198

@palmtown

Description

@palmtown

Hello,

In sporadic featherjs node startups, I am seeing nodes crash with the error as shown below. In short, I traced it to file (/api/node_modules/feathers-sync/lib/core.js line 35, specifically service._emit(event, data, hook);

In short, what is happening is that feathers-sync loads and starts receiving events before the app.mixins function is executed. This functions creates the service._emit function. Given that there is no try/cache or a check to ensure the function exists, feathers simply crashes.

A simply solution would be to check to ensure the function exists before attempting to execute it. I could submit a PR if requested.

Steps to reproduce

  1. Initiate continous events within a cluster that has feathers-sync installed.
  2. Startup a new feathersjs node with feathers-sync integrated
  • Tell us what broke. The more detailed the better.

feathersjs crashed with the following error:

TypeError: service._emit is not a function
at Function. (/api/node_modules/feathers-sync/lib/core.js:38:15)
at Function.emit (node:events:513:28)
at msgFromRedisHandler (/api/node_modules/feathers-sync/lib/adapters/redis.js:22:11)
at PubSub._PubSub_emitPubSubMessage (/api/node_modules/@redis/client/dist/lib/client/pub-sub.js:294:9)
at PubSub.handleMessageReply (/api/node_modules/@redis/client/dist/lib/client/pub-sub.js:233:93)
at Object.onReply (/api/node_modules/@redis/client/dist/lib/client/commands-queue.js:40:87)
at RESP2Decoder.write (/api/node_modules/@redis/client/dist/lib/client/RESP2/decoder.js:119:26)
at RedisCommandsQueue.onReplyChunk (/api/node_modules/@redis/client/dist/lib/client/commands-queue.js:154:72)
at RedisSocket. (/api/node_modules/@redis/client/dist/lib/client/index.js:410:84)
at RedisSocket.emit (node:events:513:28)

Expected behavior

feathersjs should not crash

Actual behavior

feathersjs crashed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions