Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state is undefined #4

Open
binarykitchen opened this issue May 27, 2016 · 11 comments
Open

state is undefined #4

binarykitchen opened this issue May 27, 2016 · 11 comments

Comments

@binarykitchen
Copy link

binarykitchen commented May 27, 2016

I see this error. Here the trace from minified code but hope it gives you some clues what the problem is:

#videomail > require<[56]</</Writable.prototype.write@https://videomail.io/js/main-36bb504261.min.js:15125:40
require<[26]</</Duplexify.prototype._write@https://videomail.io/js/main-36bb504261.min.js:9893:169
doWrite@https://videomail.io/js/main-36bb504261.min.js:15019:128
writeOrBuffer@https://videomail.io/js/main-36bb504261.min.js:15015:8
require<[56]</</Writable.prototype.write@https://videomail.io/js/main-36bb504261.min.js:15126:7
writeStream@https://videomail.io/js/main-36bb504261.min.js:18666:188
draw@https://videomail.io/js/main-36bb504261.min.js:18802:27

Taken from latest Firefox

@binarykitchen
Copy link
Author

But Chrome tells me a different trace:

collectLogger.js:49 #videomail > TypeError: Cannot read property 'ended' of undefined
    at DestroyableTransform.Writable.write (https://videomail.io/js/main-36bb504261.min.js:15125:45)
    at Duplexify._write (https://videomail.io/js/main-36bb504261.min.js:9893:184)
    at doWrite (https://videomail.io/js/main-36bb504261.min.js:15019:135)
    at writeOrBuffer (https://videomail.io/js/main-36bb504261.min.js:15015:8)
    at Duplexify.Writable.write (https://videomail.io/js/main-36bb504261.min.js:15126:7)
    at writeStream (https://videomail.io/js/main-36bb504261.min.js:18666:195)
    at draw (https://videomail.io/js/main-36bb504261.min.js:18802:27)

Weird

@binarykitchen
Copy link
Author

Using latest websocket-stream package, where Duplexify.Writable.write() is triggered

@binarykitchen
Copy link
Author

binarykitchen commented May 27, 2016

Debugged more in Chrome. Problem is that part of code. state is undefined here.

Writable.prototype.write = function (chunk, encoding, cb) {
  var state = this._writableState;
  var ret = false;

  if (typeof encoding === 'function') {
    cb = encoding;
    encoding = null;
  }

  if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;

  if (typeof cb !== 'function') cb = nop;

  if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
    state.pendingcb++;
    ret = writeOrBuffer(this, state, chunk, encoding, cb);
  }

  return ret;
};

@binarykitchen
Copy link
Author

Socket is not destroyed, not ended yet. Using node v6.20 here.

@binarykitchen
Copy link
Author

binarykitchen commented May 27, 2016

There is another weird thing: if I run my code locally, this does not happen. Only on my remote server upon deployment. Maybe a firewall issue?

@binarykitchen
Copy link
Author

any advice?? would be good because it's breaking my site. thanks

@mcollina
Copy link

Can you reproduce it? You can try with wireshark to get a capture of the latest packet sent that triggers it.

@binarykitchen
Copy link
Author

honestly, i have no idea how to reproduce - only happens on my remote server, not on my local server. and what exactly should i capture on wireshark? you can see it yourself, it's the site www.videomail.io - just hit on the record button and then that error happens every time :(

any quick advice would be very much appreciated - thanks

@binarykitchen
Copy link
Author

@mcollina I found out, that this only happens when code is minified. Does not happen when not minified. I am minifying the client side code with gulp uglify like this

        .pipe(plugins.if(settings.server.minify.js, plugins.uglify({
            mangle: false, // because of angularjs :(

            // keep line breaks for easier locating of weird errors (temporary)
            output: {
                "beautify":     true, // Add new lines
                "indent_level": 0,    // Don't add indentation
                "indent_start": 0
            }
        })))

@binarykitchen
Copy link
Author

@mcollina to reproduce I guess you try to uglify some code that uses Duplexify and then see how it goes

@giulianok
Copy link

I'm having the same issue when I use sails and google-storage. If I disable sails, Google Storage works perfectly.
GS uses createWriteStream which is failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants