node-x11
node-x11 copied to clipboard
Error: write after end
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.
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 )
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.
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.
@jmccandles146 what's your OS?
centOS-7
@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
is it the connection error with MongoDB
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)
My bad. The issue was recreating and terminating the x11 server for every command I executed...