geeklearningio / gl-vsts-tasks-yarn

Yarn Package Manager Visual Studio Team Services Build and Release Management extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected token < in JSON at position 0

ecraig12345 opened this issue · comments

Are you reporting a bug or a feature request ?

  • Bug
  • Feature request

Description

YarnInstaller intermittently fails with ##[error]Unexpected token < in JSON at position 0

Example build with failure

The failure is not at all consistent, but it seems to disappear for weeks at a time and then come back (but still only intermittently).

Expected behavior

The task either succeeds, or fails with a meaningful error.

Reproduction

Task configuration (found in this template file):

  - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@3
    displayName: 'Use Yarn 1.19.x'
    inputs:
      versionSpec: 1.19.x
      checkLatest: true
      includePrerelease: false

Overall pipeline yaml

Pipeline in ADO

Unfortunately, the failure is infrequent/random enough that we'd have to leave System.Debug enabled for a few hours or days, which is probably not feasible.

My guess is that the culprit is these lines, and that the server at https://publicblobs.geeklearning.io/yarn/tarballsV2.json is occasionally returning an HTML error page which obviously can't be parsed as JSON.

await downloadFile(
"https://publicblobs.geeklearning.io/yarn/tarballsV2.json",
yarnVersionsFile
);
let yarnVersions = JSON.parse(
fs.readFileSync(yarnVersionsFile, { encoding: "utf8" })

System information

VSTS or TFS:

  • VSTS
  • TFS

Agent:

  • Hosted
  • Custom

OS:

  • Windows
  • Mac
  • Linux

Yarn version:
1.19.x

Node version:
12.18.4

see #103