Gradle build reports invalid stream header: ED000573

I encounter building JUnit 5 with Gradle wrapper version 3.2.1 (since 3.2?) invoked by IntelliJ 2016.3 the following error on one of my machines. It happens approximately every second call of a simple build, with or without --debug:

10:18:58.144 [DEBUG] [org.eclipse.jgit.util.FS] readpipe [bash, --login, -c, which git],C:\Users\...
10:18:58.208 [DEBUG] [org.eclipse.jgit.util.FS] readpipe may return 'E r r o r :   0 x 8 0 0 7 0 0 5 7 '
10:18:58.208 [DEBUG] [org.eclipse.jgit.util.FS] remaining output:

10:18:58.208 [DEBUG] [org.eclipse.jgit.util.FS]  
10:18:58.208 [DEBUG] [org.eclipse.jgit.util.FS]  
10:18:58.209 [DEBUG] [org.eclipse.jgit.util.FS]  
10:18:58.209 [DEBUG] [org.eclipse.jgit.util.FS] readpipe rc=-1
invalid stream header: ED000573

The daemon produces an error message, which reads:

...
10:13:35.185 [WARN] [org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler] Unable to execute command Build{id=13b55cf8-a28d-40a7-ae40-c48c18887df7.1, currentDir=R:\dev\workspaces\idea16\junit5} from socket connection from /127.0.0.1:63247 to /127.0.0.1:63248. Dispatching the failure to the daemon client
org.gradle.internal.remote.internal.MessageIOException: Could not write message BuildEvent[event=org.gradle.tooling.internal.provider.events.DefaultOperationFinishedProgressEvent@70fd4f98] to '/127.0.0.1:63248'.
	at org.gradle.internal.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:111)
	at org.gradle.launcher.daemon.server.SynchronizedDispatchConnection.dispatch(SynchronizedDispatchConnection.java:51)
	at org.gradle.launcher.daemon.server.DefaultDaemonConnection.event(DefaultDaemonConnection.java:130)
...

I can provide the entire zipped daemon log, if needed.

What’s strange is, that if re-run the same build after the error occured, it often succeeds.