Skip to content
This repository has been archived by the owner on Dec 29, 2024. It is now read-only.

Handle JSON parse error on multiple build stream data chunks #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bryanlovely
Copy link

Where the streamed data to docker.buildImage is large (for instance in a large app with 100+ modules), a single message can be split among multiple chunks, in which case JSON.parse(data) will throw an error and the build will fail out.

This change temporarily adds the contents of data into a variable cumulativeData. If JSON.parse(cumulativeData) fails, it will just go on to the next chunk, add it to cumulativeData and try again. If it succeeds, it will send the parsed data to the log and clear cumulativeData until the next chunk.

Also, just to be sure nothing hangs around, cumulativeData is cleared on both error and end states of the stream.

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

Successfully merging this pull request may close these issues.

1 participant