Giter Site home page Giter Site logo

rob-- / cluster-messages Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 2.0 23 KB

Easily send messages between workers and the master with callbacks in Node.js

License: MIT License

JavaScript 100.00%
clusters nodejs javascript event-listener eventemitter

cluster-messages's People

Contributors

rob-- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ccckblaze seydx

cluster-messages's Issues

Apparent bug in setTimeout function

Hi,

I see this code in your package:

        /* This should not actually be needed, but to be 100% safe in case
         * messages between the master and worker processes are lost,
         * delete the callback function after a set timeout to prevent permanent memory hogging. */
        setTimeout(function(){
            if(this.callbacks.hasOwnProperty(id)){
                delete this.callbacks[id]
            }
        }, this.callbackTimeout)

This causes exceptions like the following:

/usr/src/app/node_modules/cluster-messages/index.js:48
            if(this.callbacks.hasOwnProperty(id)){
                             ^
TypeError: Cannot read property 'hasOwnProperty' of undefined
    at Timeout.<anonymous> (/usr/src/app/node_modules/cluster-messages/index.js:48:30)

I believe the reason is that when the timeout function runs, "this" is a Timer object, and not the ClusterMessages object... and so the "this.callbacks" is undefined.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.