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

Error: write after end #142

Open
johannesjo opened this issue Apr 24, 2017 · 9 comments
Open

Error: write after end #142

johannesjo opened this issue Apr 24, 2017 · 9 comments

Comments

@johannesjo
Copy link

johannesjo commented Apr 24, 2017

I'm trying to get a list of all open windows. Seems to me like an actual issue with node-x11 and not x11 itself:

This is the stacktrace:

Error: write after end
    at writeAfterEnd (_stream_writable.js:193:12)
    at Socket.Writable.write (_stream_writable.js:244:5)
    at Socket.write (net.js:658:40)
    at UnpackStream.<anonymous> (/home/user/app/node_modules/x11/lib/xcore.js:82:16)
    at emitOne (events.js:96:13)
    at UnpackStream.emit (events.js:188:7)
    at UnpackStream.flush (/home/user/app/node_modules/x11/lib/unpackstream.js:311:15)
    at XClient.req_proxy [as GetProperty] (/home/user/app/node_modules/x11/lib/xcore.js:231:37)
    at X.InternAtom (/home/user/app/x11-wrapper.js:99:7)
    at ReadFixedRequest.callback (/home/user/app/node_modules/x11/lib/xcore.js:545:21)

This is the code I'm running:

X.InternAtom(false, '_NET_CLIENT_LIST', (err, atomId) => {
    console.log(atomId);
    X.GetProperty(0, root, atomId, X.atoms.CARDINAL, 0, 100000, (err, prop) => {
      console.log('HERE', prop.data, prop.data.toString());
    });
  });

_NET_CLIENT_LIST_STACKING and _WIN_CLIENT_LIST result in the same error. So does leaving out the additional parameters.

@sidorares
Copy link
Owner

What's your DISPLAY look like? Is it local connection? 'writeAfterEnd' means initial connection was successful but later server unexpectedly closed connection. Might be authentication issue ( afaik this library only supports MIT-MAGIC-COOKIE-1 method - see https://en.wikipedia.org/wiki/X_Window_authorization )

@johannesjo
Copy link
Author

Thanks for getting back to me. What do you mean by display? The environment variable? That's :1. And yes it is a local connection.

@jmccandles146
Copy link

Error: write after end
at writeAfterEnd (_stream_writable.js:193:12)
at WriteStream.Writable.write (_stream_writable.js:240:5)
at log (/usr/local/lib/node_modules/genieacs/lib/logger.js:260:15)
at Object.error (/usr/local/lib/node_modules/genieacs/lib/logger.js:279:3)
at process. (/usr/local/lib/node_modules/genieacs/lib/server.js:77:10)
at emitOne (events.js:96:13)
at process.emit (events.js:188:7)
at process._fatalException (bootstrap_node.js:296:26)
issue persist , need a help

@sidorares
Copy link
Owner

@jmccandles146 what's your OS?

@jmccandles146
Copy link

centOS-7

@sidorares
Copy link
Owner

@jmccandles146 it looks to me that error is completely unrelated to node-x11. genieacs loggers tries to write to a socket after it was closed ( Stream is process stderr - https://github.com/zaidka/genieacs/blob/ec1360217b68e2947c47f8b3a17ea97af7a773f5/lib/logger.js#L38 ) something closes stderr fd

@jmccandles146
Copy link

is it the connection error with MongoDB

@johannesjo
Copy link
Author

I get the same when I try to get all the properties of a window, like in this smoke test:

    X.ListProperties(id, function(err, props) {
        props.forEach(function(p) {
            X.GetProperty(0, id, p, 0, 0, 10000000, function(err, propValue) {
                X.GetAtomName(propValue.type, function(err, typeName) {
                    X.GetAtomName(p, function(err, propName) {
                        decodeProperty(typeName, propValue.data, function(decodedData) {
                            console.log(propName + '(' + typeName + ') = ' + decodedData);
                        });
                    });
                });
            });
        })   
    });
    X.on('event', console.log);
    X.on('error', console.error);
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
    at writeAfterEnd (_stream_writable.js:243:12)
    at Socket.Writable.write (_stream_writable.js:291:5)
    at UnpackStream.<anonymous> (/home/user/myproject/node_modules/x11/lib/xcore.js:82:16)
    at UnpackStream.emit (events.js:189:13)
    at UnpackStream.flush (/home/user/myproject/node_modules/x11/lib/unpackstream.js:311:15)
    at XClient.req_proxy [as GetProperty] (/home/user/myproject/node_modules/x11/lib/xcore.js:231:37)
    at /home/user/myproject/lib/x11Wrapper.js:222:9
    at Array.forEach (<anonymous>)
    at /home/user/myproject/lib/x11Wrapper.js:221:11
    at ReadFixedRequest.callback (/home/user/myproject/node_modules/x11/lib/xcore.js:545:21)

@johannesjo
Copy link
Author

My bad. The issue was recreating and terminating the x11 server for every command I executed...

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