All jobs

Fix THREE.Geometry Is Not a Constructor After a three.js Upgrade

Yes. An agent reproduces the TypeError from r125 on, rewrites each Geometry to a BufferGeometry, finds the release the bundler can still parse and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent clones the repository into its own cloud sandbox and reads where Geometry is used. In a WebGL library like Netflix/vizceral, package.json pins three at ^0.106.2, builds with webpack --bail --mode=production twice under build:js, lints with eslint src --fix and has no test script; the README says the project is not actively maintained. src/base/connectionView.js line 239 creates new THREE.Geometry() for an interactive line, passes it to THREE.Line at line 246 and later sets geometry.vertices[0], vertices[1] and verticesNeedUpdate = true at lines 354 to 356; src/region/regionConnectionView.js does the same at lines 29, 38 and 48 to 50; src/vizceral.js line 110 creates one and never uses it. Lines 112 to 115 of connectionView.js and line 40 of trafficGraphView.js call geometry.addAttribute on a BufferGeometry.

Then it reproduces the error release by release with require('three') and the same statement. On r106 and r124 new THREE.Geometry() works. On 0.125.0 THREE.Geometry is undefined and the statement throws TypeError: THREE.Geometry is not a constructor, while a copy still exists at examples/jsm/deprecated/Geometry.js; r126 removes Face3 too; by the current release, 0.187.0, the deprecated file is gone and require('three') prints a THREE_CJS_DEPRECATED warning. BufferGeometry.prototype.addAttribute exists through r125 and is gone by 0.183.0; its replacement, setAttribute, is absent on r106 and present from r110. The build itself passes at every one of these releases, because webpack does not check runtime members, so the break would surface in the browser on the first render.

The rewrite is mechanical. Each two-vertex line becomes new THREE.BufferGeometry().setFromPoints([start, end]), and the two update sites set geometry.attributes.position.setXYZ(0, ...) and setXYZ(1, ...) then position.needsUpdate = true, which the agent checks on 0.187.0 by reading back the six floats it wrote. The five addAttribute calls become setAttribute with the same arguments, which exists from r110 and so on every release the pull request can land on, and the unused this.geometry in vizceral.js is deleted.

The last step is picking a release the toolchain can bundle. Webpack 4 on a current Node needs NODE_OPTIONS=--openssl-legacy-provider to run at all, and it parses three's module build up to 0.183.0; from 0.185.0 the build fails with Module parse failed: Unexpected token at a static { block in three.core.js. The pull request therefore pins the newest release webpack 4 parses and names the webpack 5 upgrade as the step that lifts the pin, rather than mixing a bundler migration into the geometry rewrite.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "This WebGL library throws \"TypeError: THREE.Geometry is not a constructor\" after upgrading three. Read package.json and every file that uses the three API first, and list each Geometry, Face3, addAttribute and vertices usage with its line. Install the locked three and run a script that executes the same constructor calls to show they work; then install the release that removed Geometry and the current release, quote the error from each, and note which other members those releases removed. Rewrite each Geometry as a BufferGeometry with the same vertices and the same update path, replace removed method names, delete any geometry that is never used, and check the rewritten update code on the current release by reading back the positions it wrote. Run the project's build at the locked and the new release, and if the bundler cannot parse the current release, pin the newest one it can and say which later step lifts that pin. Open a pull request that quotes the failing and passing checks.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request touching src/base/connectionView.js, src/region/regionConnectionView.js, src/vizceral.js, src/base/trafficGraphView.js, package.json and the lockfile: three Geometry constructions replaced or removed, two vertex update paths rewritten against attributes.position, five addAttribute calls renamed, and three pinned to the newest release webpack 4 parses. The description quotes the TypeError on 0.125.0 and 0.187.0, the parse error at 0.185.0 with its file, the six positions read back after an update on 0.187.0, and the build:js output at the old and new pin, including the NODE_OPTIONS flag it needed.

A reviewer checks that each rewritten line still has two vertices and updates both, that setAttribute carries the same attribute names and item sizes as before, and that nothing else in the five files changed. The run's record holds every install, script and build with its full output, so each release boundary can be read rather than taken on trust.

Run it on every Monday morning

Add an automation to the Project with this prompt and a schedule trigger, cron set to 0 9 * * 1 in your timezone. Each Monday one run bumps three, executes the constructor calls the code makes, runs the build and opens one pull request on its own branch when something broke; a week already on the newest release the bundler parses opens nothing, and a week where the rewrite cannot read back the positions it wrote ends needs_review with the output attached.

The same body works from your own code with POST /o/{org}/sessions and an API key when a dependency bot's three bump passes CI and then breaks the page; send a request_id that is a UUID v5 of the bot's pull request number so a retried start returns the same run, and the key's webhook_url receives run.completed or run.failed with the session URL when it ends.

The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.

Why run it on Rush?

A green build is the trap here. Webpack bundles a THREE.Geometry that no longer exists without a word, and the TypeError waits for the first user to open the graph. The agent executes the actual constructor calls in its sandbox at each release, keeps every command and its output in the run's record, and so names the release that removed each member instead of inferring it from release notes.

An unmaintained library also drags its toolchain into the decision: a bundler that needs a legacy OpenSSL flag and cannot parse the newest three. The agent finds that boundary by building, pins what works, and writes the next step into the pull request, so the reviewer gets one rewrite they can merge and one upgrade they can plan rather than both tangled together.

Frequently asked questions

Why did three remove Geometry?

Geometry kept vertices and faces as JavaScript objects and was converted to typed arrays on every upload; BufferGeometry holds the typed arrays directly. r125 removed Geometry from the core build and left a copy under examples/jsm/deprecated/, and later releases dropped that copy too, so on the current release there is no import that brings it back.

Why not import the deprecated Geometry file?

It only exists in a window of releases after r125, and it is gone on 0.187.0, so it buys time rather than a fix. The rewrite to BufferGeometry with setFromPoints is a few lines per site and works on r106 as well as the current release, which is why the pull request does it now.

Why pin an older three instead of the current release?

The repository builds with webpack 4, whose parser stops at the static { blocks three's module build uses from 0.185.0. The pull request pins the newest release that bundles, 0.183.0 in this run, and names the webpack 5 upgrade as the step that lifts the pin. Ask for both in the prompt if you want the bundler migrated in the same change.

Does the build need anything else on a current Node?

Webpack 4 uses an MD4 hash that OpenSSL 3 disables, so build:js stops with ERR_OSSL_EVP_UNSUPPORTED until NODE_OPTIONS=--openssl-legacy-provider is set. The agent sets it for its own runs and records it in the pull request as a CI note rather than changing the build script.

More jobs like this: Upgrade dependencies weekly

Keep reading