WordPress/wordpress-playground

Flaky build when generating Blueprint JSON schema

adamziel opened this issue · 1 comments

Occasionally, a CI build fails when generating the JSON schema. I wasn't able to reproduce this problem locally.

Here's an example:

https://github.com/WordPress/wordpress-playground/actions/runs/6980311277/job/18995331724?pr=788

/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ts-json-schema-generator/dist/src/SchemaGenerator.js:67
        throw new NoRootTypeError_1.NoRootTypeError(fullName);
              ^

NoRootTypeError: No root type "Blueprint" found
    at SchemaGenerator.findNamedNode (/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ts-json-schema-generator/dist/src/SchemaGenerator.js:67:15)
    at SchemaGenerator.getRootNodes (/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ts-json-schema-generator/dist/src/SchemaGenerator.js:43:26)
    at SchemaGenerator.createSchema (/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ts-json-schema-generator/dist/src/SchemaGenerator.js:22:32)
    at file:///home/runner/work/wordpress-playground/wordpress-playground/packages/playground/blueprints/bin/generate-schema.js:17:44
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  type: 'Blueprint'
}

Most likely, there's some race condition at play and the schema generator runs before the type declarations are ready. It shouldn't be the case, since the NX schema generation task has a dependency set up as follows:

		"build:blueprint-schema": {
			"executor": "nx:run-commands",
			"options": {
				"commands": [
					"node packages/playground/blueprints/bin/generate-schema.js"
				],
				"parallel": false
			},
			"dependsOn": ["build:rollup-declarations"]
		}

However, it's still happening.

Proposed solution

Tracking the race condition might be challenging, let's start by adding a simple retry.

It seems like #790 and project.json changes in #801 solved this problem!