feathersjs-ecosystem / feathers-sync

Synchronize service events between Feathers application instances
MIT License
222 stars 41 forks source link

Bulk patching a service from within another service returns null values #96

Closed rlunden closed 5 years ago

rlunden commented 5 years ago

Steps to reproduce

Issue occurs when running node in cluster mode while using feathers-sync.

Consider the following hook in service foo after get.

const updateBar = async function (context) {
  await context.app.service('bar').patch(
    null,
    {
      text: 'bar'
    },
    {
      query: {}
    }
  );

  return context;
};

It patches all bar rows. However, when clients receive this event through websocket null will be returned for the bar rows. Server application was started using pm2 start src/ -i 2. Worth mentioning that feathers-client was used in an angular app that basically only performs a request to the API in order to reproduce the problem. This issue only occurs when using feathers-sync with multiple processes.

Expected behavior

When bulk patching (not tried create, update, remove etc) another service from within a service the values of the patched rows should be returned through websocket.

Actual behavior

When bulk patching another service from within a service null values of the patched rows are returned through websocket. Screenshot showing the returned null values.

System configuration

Running feathers-sync with redis.

Module versions (especially the part that's not working):

{
  "name": "feathers-sync-bug-api",
  "description": "",
  "version": "0.0.0",
  "homepage": "",
  "main": "src",
  "keywords": [
    "feathers"
  ],
  "author": {},
  "contributors": [],
  "bugs": {},
  "directories": {
    "lib": "src",
    "test": "test/"
  },
  "engines": {
    "node": "^8.0.0",
    "yarn": ">= 0.18.0"
  },
  "scripts": {
    "test": "yarn run eslint && yarn run mocha",
    "eslint": "eslint src/. test/. --config .eslintrc.json",
    "dev": "nodemon src/",
    "start": "node src/",
    "mocha": "mocha test/ --recursive --exit"
  },
  "dependencies": {
    "@feathersjs/configuration": "^2.0.4",
    "@feathersjs/errors": "^3.3.4",
    "@feathersjs/express": "^1.2.7",
    "@feathersjs/feathers": "^3.2.3",
    "@feathersjs/socketio": "^3.2.6",
    "feathers-hooks-common": "^4.17.10",
    "feathers-rest": "^1.8.1",
    "feathers-sync": "^1.0.3",
    "feathers-sequelize": "^3.1.2",
    "mysql2": "^1.6.1",
    "sequelize": "^4.39.0",
    "compression": "^1.7.3",
    "cors": "^2.8.4",
    "helmet": "^3.13.0",
    "serve-favicon": "^2.5.0",
    "winston": "^3.0.0"
  },
  "devDependencies": {
    "eslint": "^5.6.1",
    "mocha": "^5.2.0",
    "nodemon": "^1.18.4",
    "request": "^2.88.0",
    "request-promise": "^4.2.2"
  }
}

NodeJS version: 8.12.0

Operating System: Linux (Ubuntu 16.04)

Browser Version: Google Chrome 69.0.3497.100

React Native Version: Not applicable

Module Loader: CommonJS

Github repository: Github repository reproducing this issue

rlunden commented 5 years ago

This issue doesn't seem to be within the feathers-sync codebase but in Feathers itself. See our proposed solution: https://github.com/feathersjs/feathers/pull/1061