All jobs

Fix "error:0308010C:digital envelope routines::unsupported" in a Create React App

Yes. The agent reproduces the OpenSSL error on your Node version, traces it to webpack 4, and opens a pull request that fixes the build without a runtime flag.

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 reproduces the failure before it changes anything, and records which commands fail and which do not. In a project like the-road-to-learn-react/hackernews-client, package.json pins react-scripts 3.1.0 and the lockfile resolves webpack to 4.39.1. On Node 22, npm run build and npm start both stop with Error: error:0308010C:digital envelope routines::unsupported and code: 'ERR_OSSL_EVP_UNSUPPORTED', while npm test passes all nine tests. That split is the first clue: Jest never goes through webpack, so the problem is in the bundler and not in the application.

It then reads the stack trace down to the cause. The error is thrown from webpack/lib/util/createHash.js, called by NormalModule._initBuildHash, and webpack/lib/WebpackOptionsDefaulter.js sets output.hashFunction to md4. Node 17 and later are built on OpenSSL 3, which moved MD4 out of the default provider, so every webpack 4 build fails at the first module it hashes. The agent also reads .travis.yml, where node_js: stable means CI follows the newest Node release. That explains how a repository with no recent commits starts failing: the Node version moved, the code did not.

There are two fixes and the agent tries both in order to compare them. Setting NODE_OPTIONS=--openssl-legacy-provider makes the old build compile, and the agent confirms it does. It does not recommend it as the fix: the variable has to be added to every script, CI job and hosting setting, it turns on legacy algorithms for the whole Node process, and a Node 16 runtime refuses to start with it (node: --openssl-legacy-provider is not allowed in NODE_OPTIONS), so a team with mixed Node versions trades one failure for another. react-scripts 4.0.3 is not a fix either, since it still depends on webpack 4.

The fix that removes the cause is react-scripts 5.0.1, which moves to webpack 5. Its createHash loads webpack's own MD4 implementation from webpack/lib/util/hash/md4, so hashing no longer asks OpenSSL for the algorithm. On this repository the upgrade needs no source change: the build compiles, the dev server starts, and the same nine tests and four snapshots pass on the newer Jest it brings. The agent checks what else moved with it. package-lock.json is rewritten from lockfileVersion 1 to 3, the three JavaScript chunks in build/static/js become one main file, and build/ no longer contains service-worker.js or a precache manifest. It also flags react-addons-test-utils 15.6.2 in devDependencies: once the lockfile is rewritten, its peer requirement on react-dom ^15.4.2 makes the next npm install of any new package stop with ERESOLVE.

Start it with one API call

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

{
  "agent": "claude",
  "input": "The build of this Create React App project fails with error:0308010C:digital envelope routines::unsupported. Reproduce it first: print node --version, run npm ci, then npm test, npm run build and npm start (stop the dev server once it has compiled or failed), and record which of them fail and the first frames of the stack trace. Find the line in node_modules that picks the hash algorithm and name the webpack and react-scripts versions from the lockfile. Read every CI file and say which Node version it uses. Then test two fixes on separate branches of work and compare them: (1) NODE_OPTIONS=--openssl-legacy-provider, and (2) upgrading react-scripts to the latest release. For the upgrade, run the build, the tests and the dev server again, list what changed in build/ compared with a build made under option 1, and say whether any source file had to change. Check whether a further npm install of an unrelated package still works after the upgrade, and fix the cause if it does not. Do not add the legacy provider flag to any script. Pin the Node version CI uses to a current LTS instead of a moving tag. Open a pull request for the upgrade with the output of every command before and after.",
  "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

A pull request that changes react-scripts in package.json, rewrites package-lock.json, removes the unused react-addons-test-utils, and replaces node_js: stable in the CI file with a fixed LTS version. The description opens with the reproduction: the Node version, the three commands and their results, and the stack frames that lead to createHash. It then states the cause in two sentences and shows the output of both fixes.

The comparison is the part a reviewer reads closely. The description lists the contents of build/ under the old toolchain and the new one, and names the two differences that can matter in production: the chunk file names change, and no service worker file is emitted. An app that calls serviceWorker.register() would need a follow-up for that; this one calls unregister(), and the description says which case applies.

Before merging, the reviewer checks that no script or CI file gained --openssl-legacy-provider, that the test totals before and after are the same, and that the lockfile diff comes from the single react-scripts change and the one removal, not from an unrelated refresh of every dependency range.

Run it on every failed build on a new Node version

The error tends to arrive without a commit: a CI image or a hosting platform moves its default Node forward and the next build fails. Create an automation in the Project that holds the repository, with this prompt and a github trigger on workflow_run.failure. Workflows fail for many reasons, so begin the saved prompt with a guard: if the failed log does not contain digital envelope routines, report that the cause lies elsewhere and end. The trigger adds the event after the prompt and fills in nothing; the prompt is the only instruction.

Keep the automation's max runs per hour low, since a broken build fails every workflow that follows it and one run is enough. To start it from a build system that is not GitHub Actions, have a handler on your server receive that system's failure notification and send this body to POST /o/{org}/sessions, with a request_id that is a UUID v5 of the build id so a repeated notification returns the run already started.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

The quick answer to this error is a flag, and it is everywhere. Whether the flag is acceptable, and what the real fix changes, can only be settled by running both on the actual repository. The agent does that in its own sandbox: it installs the locked dependencies from nothing, runs each command on the old and new toolchain, and keeps the full output in the transcript at GET /o/{org}/sessions/{id}/messages. The pull request's claim that no source file had to change is backed by a test run and a build, not by reading release notes.

A clean machine also matters for the reproduction itself. A developer's laptop may be on an older Node through a version manager, or may already export the flag from a shell profile, and then the build works there while it fails in CI. The sandbox starts with neither, so what the run reports is what a fresh runner sees.

Frequently asked questions

Is NODE_OPTIONS=--openssl-legacy-provider safe to use?

It makes the build pass, and for a build step that only hashes file contents the practical risk is small. The cost is elsewhere: it must be set everywhere the build runs, it applies to the whole process, and Node 16 exits with an error when it sees it. Treat it as a way to ship today while the upgrade is reviewed, not as the fix.

Can I fix it by downgrading Node instead?

Node 16 builds the project without changes because it is linked against OpenSSL 1.1.1. It is also past its end of life, and hosting platforms remove old runtimes on their own schedule. Pinning CI to an old Node moves the failure to a later date and adds unpatched tooling in the meantime.

Why do my tests pass when the build fails?

The test script runs Jest, which transforms files with Babel and never asks webpack to hash a module. Only start and build go through webpack 4 and its MD4 call. That is why the agent runs all three commands: a green test job says nothing about whether the app can be built.

Will upgrading react-scripts from 3 to 5 break my app?

On the fixture this page was written against, nothing in src had to change. Larger apps can meet real differences: webpack 5 no longer adds Node core polyfills to browser bundles, the bundled ESLint and Jest are newer majors, and the service worker is no longer generated by default. The agent runs the build, tests and dev server and reports each failure with its cause instead of assuming the upgrade is clean.

More Create React App jobs

More jobs like this: Fix a bug from an alert

Keep reading