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 / to / Dispatching the failure to the daemon client
org.gradle.internal.remote.internal.MessageIOException: Could not write message BuildEvent[] to '/'.
	at org.gradle.internal.remote.internal.inet.SocketConnection.dispatch(
	at org.gradle.launcher.daemon.server.SynchronizedDispatchConnection.dispatch(
	at org.gradle.launcher.daemon.server.DefaultDaemonConnection.event(

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.