nodejs / nodejs-dist-indexer

An application to create nodejs.org distribution index files: index.json and index.tab
MIT License
16 stars 15 forks source link

`Unexpected token : in JSON at position 3` for rc builds #24

Open richardlau opened 12 months ago

richardlau commented 12 months ago

As part of https://github.com/nodejs/build/issues/3524 I've manually run the promotion script on the non-release builds, and I've noticed lots of errors like the following for the rc builds:

SyntaxError: Unexpected token : in JSON at position 3
    at JSON.parse (<anonymous>)
    at /usr/lib/node_modules/nodejs-dist-indexer/dist-indexer.js:119:19
    at BufferListStream._callback (/usr/lib/node_modules/nodejs-dist-indexer/dist-indexer.js:101:5)
    at BufferListStream.end (/usr/lib/node_modules/nodejs-dist-indexer/node_modules/bl/bl.js:65:10)
    at DestroyableTransform.onend (/usr/lib/node_modules/nodejs-dist-indexer/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:523:10)
    at Object.onceWrapper (node:events:627:28)
    at DestroyableTransform.emit (node:events:525:35)
    at /usr/lib/node_modules/nodejs-dist-indexer/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:965:16
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
(ignoring error fetching npm version for node/v0.10.44-rc.1)

My guess would be that e.g. v0.10.44-rc.1 isn't mapping to a valid git reference when the substitution is done for https://github.com/nodejs/nodejs-dist-indexer/blob/860a8b4c20ebfa79bef3113527fc963cec61c60f/dist-indexer.js#L20-L22 to fetch the package.json file for npm.

richardlau commented 12 months ago

Further evidence, looking at index.json for the rc downloads, most of the version information is either the empty string or null: e.g.

    {
        "version": "v20.0.0-rc.1",
        "date": "2023-04-13",
        "files": [
            "aix-ppc64",
            "headers",
            "linux-arm64",
            "linux-armv7l",
            "linux-ppc64le",
            "linux-s390x",
            "linux-x64",
            "osx-arm64-tar",
            "osx-x64-pkg",
            "osx-x64-tar",
            "src",
            "win-arm64-7z",
            "win-arm64-zip",
            "win-x64-7z",
            "win-x64-exe",
            "win-x64-msi",
            "win-x64-zip",
            "win-x86-7z",
            "win-x86-exe",
            "win-x86-msi",
            "win-x86-zip"
        ],
        "v8": "",
        "uv": "",
        "zlib": null,
        "openssl": null,
        "modules": null,
        "lts": false,
        "security": false
    },