-
-
Notifications
You must be signed in to change notification settings - Fork 466
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
exec Stream Doesn't Emit End Event #534
exec Stream Doesn't Emit End Event #534
Comments
Ended up doing this, which gave me the expected result.
|
@DavidRusso I'm having the same issue and the solution proposed by @jankoritak didn't work for me. Did you find a solution? |
I never found a 'real' solution. I worked around by polling for completion by calling exec.inspect() via setInterval() and checking the 'Running' flag. |
… attach Workaround to the issue loosely described in apocas/dockerode#534
I am also running into this issue. The 'end' event does not fire in my case even though the command finishes. |
I'm seeing the same thing on Windows but not on Mac, where I do get the |
I can confirm that this bug exists in Windows - or at least it did when I
first commented about it here. Haven't tested in macOS.
…On Tue, Oct 20, 2020, 17:16 Phillip Hoff ***@***.***> wrote:
I'm seeing the same thing on Windows but not on Mac, where I *do* get the
end event. Which platforms are you all seeing this issue?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#534 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADXDBGZCVG76IVXFKJ5CENDSLWZVTANCNFSM4IVWDJ2Q>
.
|
FYI: It looks like it might be the same or similar to a long outstanding issue in |
Has this problem solved on windows? |
My following function never end on windows:
|
a workaround as @DavidRusso suggested:
If this bug fixed, please let me know. Thank you guys. |
I basically understand the underlying bug here (but am still working on figuring out what the right fix is). Docker heavily uses Duplex sockets: both sides of the socket can write, and receive messages on the other side. The two sides of the socket can be closed independently (e.g., you can close to tell the client to stop reading but the client is still allowed to keep writing). On Windows, we need a compatibility layer for Duplex sockets over Named Pipes. Docker uses this library: microsoft/go-winio My knowledge of Named Pipes (the underlying Windows OS primitive) is a bit sketchy…but as far as I can tell, they don’t really have a built-in notion of one-sided Close? And I think WinIO works around this by implementing it as a 0-length message, and treating that as a “close” message. See this comment: go-winio/pipe.go at d68e55cd0b80e6e3cac42e945f1cff6ddb257090 · microsoft/go-winio But because this is a fake convention, I’m not sure how common it is for other platforms / frameworks to respect this convention. I don’t think NodeJS’s implementation of Named Pipes will respect this. In particular, the NodeJS standard library tends to wrap everything in byte streams, and doesn't really give you access to the underlying messages. So NodeJS happily consumes the 0-length message and expects the socket is still open. Possible options to fix this:
|
filed a more low-level repro case here: microsoft/go-winio#257 |
docker desktop 4.12 has a compatibility shim that should fix this. |
Works for me now const runExec = async function (
container: Docker.Container,
command: string[]
) {
const exec = await container.exec({
Cmd: command,
AttachStdout: true,
AttachStderr: true,
User: 'www-data',
})
return new Promise((resolve, reject) => {
exec.start({}, (err, stream) => {
if (stream) {
stream.setEncoding('utf-8')
stream.on('data', console.log)
stream.on('end', resolve)
}
})
})
} await runExec(container, ['php', 'occ', 'config:system:set', 'enforce_theme', '--value', 'light']) $ docker -v
Docker version 20.10.18, build b40c2f6b5d
|
I use Windows but there has been no issue so far |
I want to execute a command in an already running container using "exec". For some reason, the stream returned by "exec.start()" is not emitting the "end" event. So, I have no way of knowing when the command completes and the Node process doesn't end.
Example code is below. Am I doing something wrong, or is this a bug?
The text was updated successfully, but these errors were encountered: