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

getEvents() returns incorrect object #363

Closed
igor-lemon opened this issue Apr 16, 2017 · 3 comments
Closed

getEvents() returns incorrect object #363

igor-lemon opened this issue Apr 16, 2017 · 3 comments
Labels

Comments

@igor-lemon
Copy link

Hi. Sometimes I have an error with object that returned from

docker.client.getEvents().then(e => {
      e.setEncoding('utf8');
      e.on('data', json => {
        let data = JSON.parse(json); // Error. Return invalid object
      });
    }).catch(() =>
      console.error('Failed to attach docker event listener.')
    );

Return 2 objects in 1 response.

{"Type":"volume","Action":"unmount","Actor":{"ID":"0acf94e14ae92d371a0456388a587c3eb5f6354cc3999118b65fb4db8aa8ff31","Attributes":{"container":"0e0364466473b65a49a32c4447476b7a0dc6cb16e59dcf25525de061b2458b16","driver":"local"}},"time":1492382699,"timeNano":1492382699067472864}
{"Type":"volume","Action":"unmount","Actor":{"ID":"86effcf7ee4e360a715038f3371faa0dc7bacf527cdbfd0e7299a1a374ccfb56","Attributes":{"container":"0e0364466473b65a49a32c4447476b7a0dc6cb16e59dcf25525de061b2458b16","driver":"local"}},"time":1492382699,"timeNano":1492382699067773015}

After that I have an error
image

@nlaplante
Copy link

Same behavior for a restart. Last event published actually contains 2 events:

{
   "status":"start",
   "id":"8b2409238fd79d55af99a7bd990621730b3f5f85503eb122bf497c15cbbac573",
   "from":"mariadb:latest",
   "Type":"container",
   "Action":"start",
   "Actor":{
      "ID":"8b2409238fd79d55af99a7bd990621730b3f5f85503eb122bf497c15cbbac573",
      "Attributes":{
         "image":"mariadb:latest",
         "name":"service-mysql"
      }
   },
   "time":1494349751,
   "timeNano":1494349751467159400
}{
   "status":"restart",
   "id":"8b2409238fd79d55af99a7bd990621730b3f5f85503eb122bf497c15cbbac573",
   "from":"mariadb:latest",
   "Type":"container",
   "Action":"restart",
   "Actor":{
      "ID":"8b2409238fd79d55af99a7bd990621730b3f5f85503eb122bf497c15cbbac573",
      "Attributes":{
         "image":"mariadb:latest",
         "name":"service-mysql"
      }
   },
   "time":1494349751,
   "timeNano":1494349751467253300
}
$ cat node_modules/dockerode/package.json | json version
2.4.3
$ docker --version
Docker version 17.03.1-ce, build c6d412e

@apocas
Copy link
Owner

apocas commented Oct 24, 2017

I saw this happening myself, but it seems mitigated in the latest Docker versions.

I have tried to find a way to fix the incoming JSON, but it would feel "hacked" and we had to fiddle with the data.

Are you still hitting this using the latest Docker version?

@Seikho
Copy link

Seikho commented Oct 24, 2017

I'm hitting this one in very recent versions of Docker on OSX and CentOS.
Haven't found a good way to deal with it, but I haven't found it particularly deal breaking.

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

No branches or pull requests

4 participants