Build Server - Frequent Unexpected end of JSON input while parsing near

We’re running a TeamCity build server, and frequently we’re getting the error “Unexpected end of JSON input” error. We used to get it sporadically, and now I’d say we get it fairly frequently on about 25% of our builds currently.

Cleaning the npm cache always fixes it, but we don’t really want to force cache clean before every build as that adds significant overhead and due to the fact we’ve got multiple agents running on a machine - that could be problematic if two builds do run simultaneously. Note that the errors included below, none of those runs had 2 builds running at the same time.

The errors we get are normally from different packages. We’ve got 2 agents building this project, one of which seems more unreliable than the other, however they’ve both been affected in the last 20 runs. Here are the last few example errors:

npm ERR! Unexpected end of JSON input while parsing near ‘…abel-plugin-transform’
npm ERR! Unexpected end of JSON input while parsing near ‘…"webpack-dev-middlewa’
npm ERR! Unexpected end of JSON input while parsing near ‘…^3.0.0",“store”:"^1.3’
npm ERR! Unexpected end of JSON input while parsing near ‘…ols-dock-monitor":"^1’

I guess my question is is there anything we can do to prevent this, or anything we should be investigating to save us resorting to a cache bust every build?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.