0

When I use the .create(item) method to do an INSERT from the client (within the browser) I see 1 call via websocket or REST go to feathersjs. I see one request go into Feathersjs. For an unknown reason I see 2 rows created in MySql and 2 lines in the log that say: {"message":"after: name_of_service - Method: create","level":"info"}

Using sequelize 4.42.0 and feathers-sequelize 6.0.1

I do not have the issue when running create() from within the server code, only from client.

I found https://github.com/feathersjs-ecosystem/feathers-rethinkdb/issues/80 that looked simular but is for a different DB and the explanation did not fit with MySql.

I switched to MariaDB for other reasons but obviously nothing changed.

I was using FeathersJS v3.x and upgrading to v4.x to see if that would fix it. Nope. As I work around I have been making my own insert methods but it would be nice to use the built in ones.

I tried switching between REST and websocket.

My Hooks:


const { authenticate } = require('@feathersjs/authentication').hooks;

module.exports = {
  before: {
    all: [ ], // authenticate('jwt') normally use, but deactivated to debug
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  after: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  }
};

Service:

const createService = require('feathers-sequelize');
const createModel = require('../../models/name_of_service.model');
const hooks = require('./name_of_service.hooks');

module.exports = function (app) {
    const Model = createModel(app);
    const paginate = app.get('paginate');

    const options = {
    Model,
    paginate: {
        default: 100,
        max: 2000
    }
    };

    app.use('/name_of_service', createService(options));

    const service = app.service('name_of_service');

    service.hooks(hooks);
};

I expected it to insert 1 row in MySql table. But got 2. I expected one row in the log for the after hook, but see 2. This has been happening for a couple of months and was thinking, hey, maybe I am not the only one.

2
  • what does your client call look like? Commented Sep 24, 2019 at 0:33
  • I see the duplicity with inserts: this.get().client.service('order_notes').create(obj) and updates this.get().client.service('order_notes').patch(this.get().order_notes.id, obj) Client side only sends 1 request. Commented Sep 24, 2019 at 18:26

1 Answer 1

0

Thank you everyone for your help. I found the issue. I fixed my rooky mistake by changing:

app.configure(socketio());
app.configure(socketio(function(io) {io.sockets.setMaxListeners(555);}));

To:

app.configure(socketio(function(io) {io.sockets.setMaxListeners(555);}));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.