Skip to content

Commit

Permalink
Handle unparseable data in Docker event stream
Browse files Browse the repository at this point in the history
Not clear what this actually is, but hopefully this will let us skip it,
and logging it should help diagnose the issue, if it's actually
something important (but I suspect it's actually some whitespace-only
keep-alive data or similar).
  • Loading branch information
pimterry committed Sep 8, 2022
1 parent dcf9b96 commit 192a36d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/interceptors/docker/docker-networking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ function getDockerEventStream(docker: Docker) {
EventStream.split(),
EventStream.mapSync((buffer: Buffer) => buffer.toString('utf8')),
EventStream.filterSync((line: string) => line.length > 0),
EventStream.mapSync((rawLine: string) => JSON.parse(rawLine))
EventStream.mapSync((rawLine: string) => {
try {
return JSON.parse(rawLine);
} catch (e) {
console.warn(`Unparseable Docker event data: ${rawLine}`);
return {};
}
})
);

// We expose the stream immediately, even though no data is coming yet
Expand Down

0 comments on commit 192a36d

Please sign in to comment.